これは古い質問であることは承知していますが、他の誰かが解決策を探している場合は、Zend_Controller_Action_Helper_ContextSwitch をサブクラス化するのがよいと思います。
私の場合、「*」を「すべてのアクション」のワイルドカードと見なすようにサブクラス化しました。
class My_Controller_Action_Helper_ContextSwitch extends Zend_Controller_Action_Helper_ContextSwitch {
/**
* Adds support logic for the "*" wildcard.
*
* @see Zend_Controller_Action_Helper_ContextSwitch::getActionContexts()
*/
public function getActionContexts($action = null) {
$parentContexts = parent::getActionContexts($action = null);
$contextKey = $this->_contextKey;
$controller = $this->getActionController();
if (isset($controller->{$contextKey}['*'])) {
$contexts = $controller->{$contextKey}['*'];
}
else {
$contexts = array();
}
return array_merge($parentContexts, $contexts);
}
/**
* Adds support logic for the "*" wildcard.
*
* @see Zend_Controller_Action_Helper_ContextSwitch::hasActionContext()
*/
public function hasActionContext($action, $context) {
if (!$result = parent::hasActionContext($action, $context)) {
$controller = $this->getActionController();
$contextKey = $this->_contextKey;
$contexts = $controller->{$contextKey};
foreach ($contexts as $action => $actionContexts) {
foreach ($actionContexts as $actionContext) {
if ($actionContext == $context && $action == '*') {
return true;
}
}
}
}
return $result;
}
}
私のコントローラーでは、次の構文を使用してコンテキスト スイッチをセットアップします。
$contextSwitch = $this->_helper->getHelper('contextSwitch');
$contextSwitch
->addActionContext('*', array('help'))
->initContext()
;
これにより、コントローラー内のすべてのアクションで「ヘルプ」コンテキストを利用できるようになります。
これらのサンプルは完全にはテストされておらず、完全ではありませんが、問題を解決するための出発点としては適しています。