symfony action.class.phpでの初期化処理

2011年7月20日 Posted by PURGE

アクションクラス内で、各アクション共通の変数を持たせたかったのだが、普通は下記のメソッドを使用するらしい。

public function preExecute()
{
    //共通処理
    $this->common = "共通変数";
}
public function executeIndex1()
{
    //ログ出力
    $this->getLogger()->info($this->common);
}
public function executeIndex2()
{
    //ログ出力
    $this->getLogger()->info($this->common);
}

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です