Code snippets for symfony 1.x

Navigation

Refine Tags

Snippets tagged "peytz"

JsModuleActionFilter

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

<?php
 
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');
        }
 
        $filterChain->execute();
    }
}
 
?>
 
by excessive demon on 2009-03-15, tagged 12  filter  peytz 
(2 comments)