5 php symfony1 filtering symfony-1.4
我有一个自定义过滤器做一些东西.
我希望特定模块不包含在过滤器链中.换句话说,对于这个模块,我希望我的自定义过滤器不在此模块上执行并执行其他模块.
我也使用自定义过滤器,在该过滤器内您可以检索当前模块:
<?php
class customFilter extends sfFilter
{
public function execute ($filterChain)
{
$context = $this->getContext();
if ('moduleName' == $context->getModuleName())
{
// jump to the next filter
return $filterChain->execute();
}
// other stuff
}
}
Run Code Online (Sandbox Code Playgroud)
否则,您也可以在文件中给出排除的模块filters.yml:
customFilter:
class: customFilter
param:
module_excluded: moduleName
Run Code Online (Sandbox Code Playgroud)
在班级内部:
<?php
class customFilter extends sfFilter
{
public function execute ($filterChain)
{
$context = $this->getContext();
if ($this->getParameter('module_excluded') == $context->getModuleName())
{
// jump to the next filter
return $filterChain->execute();
}
// other stuff
}
}
Run Code Online (Sandbox Code Playgroud)