すべてのコントローラーで使用できる変数を登録したいと考えています。
class testController extends Zend_Controller_Action{
public function testAction(){
echo $this->testVar;
}
...
どのように、どこで、この変数の内容を設定して、すべてのコントローラーでアクセスできるようにできますか?
すべてのコントローラーで使用できる変数を登録したいと考えています。
class testController extends Zend_Controller_Action{
public function testAction(){
echo $this->testVar;
}
...
どのように、どこで、この変数の内容を設定して、すべてのコントローラーでアクセスできるようにできますか?
class Default_Controller extends Custom_Controller_Abstract
{
public function testAction()
{
$this->content = 'Test';
}
}
class Index_Controller extends Custom_Controller_Abstract
{
public function testAction()
{
echo $this->content;
}
}
class Custom_Controller_Abstract extends Zend_Controller_Action
{
public $content;
public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array)
{
parent::__construct($request, $response,$invokeArgs);
}
}
お役に立てれば
その変数を /public/index.php で宣言するだけです。すべてのアクションは index.php から開始されるため、index.php で U を宣言すると、グローバル変数として使用できます。