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

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

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

This entry was posted in php, symfony, 技術情報. Bookmark the permalink.

コメントを残す

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