php – 在Symfony中:如何从过滤器链中排除模块
发布时间:2020-05-25 09:09:34 所属栏目:PHP 来源:互联网
导读:我有一个自定义过滤器做一些东西. 我希望特定模块不包含在过滤器链中.换句话说,对于这个模块,我希望我的自定义过滤器不在此模块上执行并执行其他模块. 我也使用自定义过滤器,在此过滤器中,您可以检索当前模块: ?phpclass customFilter extends sfFilter{ pub
我有一个自定义过滤器做一些东西. 我希望特定模块不包含在过滤器链中.换句话说,对于这个模块,我希望我的自定义过滤器不在此模块上执行并执行其他模块. 我也使用自定义过滤器,在此过滤器中,您可以检索当前模块:<?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 } } (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |