久々のEthna小ネタです。
Ethnaでのデフォルトアクション名はAppID_Action_Hogeのようなスタイルのアクション名ですが、これを変更したい場合のTIPSです。
例えば、AppID_HogeActionのようにアクションのクラス名を変更したいと思います。
AppID_Action_Hoge => AppID_HogeAction
その場合は下記のようにAppID_Controller.php内にgetDefaultActionClassメソッドをオーバーライドすることで簡単に実現できます。
ちなみに、アクションをコマンドから作る場合にコントローラに下記のコードを書いておくだけで命名規則が変更されるため、アクションを作る前にコントローラに実装しておくことがお薦めです。
また、ビュー(View)やアクションフォーム(ActionForm)などの命名規則も同様にgetDefaultViewClass, getDefaultFormClassをオーバーライドするだけです。
function getDefaultActionClass($action_name, $gateway = null) {
$gateway_prefix = $this->_getGatewayPrefix($gateway);
$postfix = preg_replace('/_(.)/e', "strtoupper('\$1')", ucfirst($action_name));
$r = sprintf("%s_%s%sAction", $this->getAppId(), $gateway_prefix ? $gateway_prefix . "_" : "", $postfix);
$this->logger->log(LOG_DEBUG, "default action class [%s]", $r);
return $r;
}