5

私はカスタムフィルターにいくつかのことをさせています。

そして、特定のモジュールをフィルターチェーンに含めないようにしたい。言い換えると、このモジュールでは、カスタムフィルターをこのモジュールで実行せず、他のモジュールで実行する必要があります。

4

1 に答える 1

3

私もカスタムフィルターを使用しており、このフィルター内で現在のモジュールを取得できます。

<?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
  }
}
于 2012-10-21T16:07:15.050 に答える