Code snippets for symfony 1.x



A simple filter for Symfony 1.2.* which embed a js per request named after /js/modules/:module_:action.js rule.

class JsModuleActionFilter extends sfFilter
    public function execute($filterChain)
        if ($this->isFirstCall()) {
            $params = $this->getContext()->getRequest()->getRequestParameters();
            //gets a module action specific js file
            $this->getContext()->getResponse()->addJavascript('modules/' . $params['module'] . '_' . $params['action'] , 'last');
by excessive demon on 2009-03-15, tagged 12  filter  peytz 

Comments on this snippet

gravatar icon
#1 Nicolas Chambrier on 2009-03-20 at 02:59

In 90% of your pages you won't have the corresponding Javascript, and your browser will load a useless 404 when trying to get this script :/

gravatar icon
#2 Loïc Vernet on 2009-03-22 at 10:25

Perhaps it would be cool to be able to activate this snippet on a module/action basis. With a flag or a yaml...