指定したアクションではフィルタを実行しないようにする
フィルタの設定で「_excludes」エントリにアクション名を指定するだけです。
カンマ区切りで複数登録も可能です。
フィルタの発動指定ですが、セクションだと複雑になりすぎると思うので
個人的にはエントリに書き込んだ方がいいかなと思ってます。
複雑になるだけでなく、セクションはmaple.iniの継承(というのかな?)に関わってくるので、GlobalFilterで指定してアクションフォルダのmaple.iniで上書きする場合にややこしくなると思います。
[Validate] name.required = "1,名前が入力されていません" _excludes = "action_foo, action_bar"
function build(&$config) { $log =& LogFactory::getLog(); foreach ($config->getConfig() as $section => $value) { $sections = explode(':', $section); $filterName = $sections[0]; // フィルタ名 if (isset($sections[1]) && $sections[1]) { // 発動するREQUEST_METHOD $method = strtoupper($sections[1]); } else { $method = 'BOTH'; } if (isset($sections[2]) && $sections[2]) { // エイリアス名 $alias = $sections[2]; } else { $alias = $filterName; } // 追加 /////////////////////////////////////////////////////// if (isset($value['_excludes'])) { $excludes = preg_split('/\s*,\s*/', $value['_excludes'], -1, PREG_SPLIT_NO_EMPTY); $container =& DIContainerFactory::getContainer(); $actionChain =& $container->getComponent("ActionChain"); $curAction = $actionChain->getCurActionName(); if (in_array($curAction, $excludes)) { continue; } $c =& $config->getConfig(); unset($c[$section]['_excludes']); } // 追加 /////////////////////////////////////////////////////// if (($method == 'BOTH') || ($method == $_SERVER['REQUEST_METHOD'])) { $filterConfig =& $config->getSectionConfig($section); if (!$this->add($filterName, $alias)) { $log->error("FilterChainへの追加に失敗しました(${section})", "FilterChain#build"); return false; } if (is_array($filterConfig) && (count($filterConfig) > 0)) { $this->setAttributes($alias, $filterConfig); } } } return true; }