2012-10-21 5 views
5

私はカスタムフィルタを使っていくつかのことをします。Symfony:フィルタチェーンからモジュールを除外する方法

そして、特定のモジュールをフィルタチェーンに含めないようにします。別の言い方をすれば、このモジュールでは私のカスタムフィルタをこのモジュールでは実行せず、他のモジュールでは実行しません。

私もカスタムフィルタを使用して、このフィルタの内側には、現在のモジュール取得することができ

答えて

3

customFilter: 
    class: customFilter 
    param: 
    module_excluded: moduleName 

内側:そうでなければ、あなたもfilters.ymlファイル内の除外モジュールを与えることができます

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

をクラス:

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

偉大な、私のために働くが、これを作るために少し変更がありますde work ---> filters.ymlの中---> "param:" "params:"ではなく –

+0

あなたはそうです、私はそれを修正しました。 – j0k

関連する問題