php – 在Symfony中:如何从过滤器链中排除模块

发布时间:2022-04-30 发布网站:脚本宝典
脚本宝典收集整理的这篇文章主要介绍了php – 在Symfony中:如何从过滤器链中排除模块脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
我有一个自定义过滤器做一些东西.

我希望特定模块不包含在过滤器链中.换句话说,对于这个模块,我希望我的自定义过滤器不在此模块上执行并执行其他模块.

我也使用自定义过滤器,在此过滤器中,您可以检索当前模块:
<?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
  }
}

否则,您还可以在filters.yML文件中提供已排除的模块:

customFilter:
  class: customFilter
  param:
    module_excluded: moduleName

在课堂上:

<?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
  }
}

脚本宝典总结

以上是脚本宝典为你收集整理的php – 在Symfony中:如何从过滤器链中排除模块全部内容,希望文章能够帮你解决php – 在Symfony中:如何从过滤器链中排除模块所遇到的问题。

如果觉得脚本宝典网站内容还不错,欢迎将脚本宝典推荐好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。