У меня есть свой собственный абстрактный класс, который расширяет Zend_Controller_Action, и все мои контроллеры расширяют этот класс. Вот мой абстрактный класс:Переменная Zend недоступна в представлении
<?php
abstract class CLG_Controller_Action extends Zend_Controller_Action
{
public $admin;
public $staff;
public $pool;
public $it;
//public $staff;
/**
*
* @var HTMLPurifier
*/
public $purifier;
public $action;
public $controller;
public function __construct(Zend_Controller_Request_Abstract $request, Zend_Controller_Response_Abstract $response, array $invokeArgs = array())
{
parent::__construct($request, $response, $invokeArgs);
if(Zend_Registry::isRegistered('admin')) {
$this->admin = Zend_Registry::get('admin');
}
if(Zend_Registry::isRegistered('staff')) {
$this->staff = Zend_Registry::get('staff');
}
if(Zend_Registry::isRegistered('pool')) {
$this->pool = Zend_Registry::get('pool');
}
$this->purifier = Zend_Registry::get('purifier');
$this->controller = $this->getRequest()->getControllerName();
$this->action = $this->getRequest()->getActionName();
$this->registerViewObjects();
}
public function postDispatch()
{
/************************************************
* Prepare JS and CSS FILES FOR THIS REQUEST
************************************************/
$action = $this->_request->getActionName();
$controller = $this->_request->getControllerName();
$this->view->headScript()->appendFile('/js/jquery-2.0.2.min.js');
if (key_exists ($this->_request->getActionName(), $this->assets))
{
$action = $this->_request->getActionName();
foreach ($this->assets [$action] ['css'] as $css)
{
$this->view->headLink()->appendStylesheet ($css , 'print');
}
foreach ($this->assets [$action] ['js'] as $js)
{
$this->view->headScript()->appendFile($js);
}
}
$css = '/css/' . $controller . '/' . $action . '.css';
$js = '/js/' . $controller . '/' . $action . '.js';
$this->view->headLink()->appendStylesheet ($css , 'print');
$this->view->headScript()->appendFile($js);
}
private function registerViewObjects()
{
// THESE ARE ALWAYS AVAILABLE IN THE VIEW
$this->view->admin = $this->admin;
$this->view->staff = $this->staff;
$this->view->pool = $this->pool;
$this->view->controller = $this->controller;
$this->view->action = $this->action;
$this->view->purifier = $this->purifier;
}
}
Однако, по некоторым причинам, переменный, зарегистрированные в registerViewObjects() не доступен в моем просмотре файлах.
Что мне здесь не хватает?
Благодаря
UPDATE: я должен сказать, что у меня есть еще один класс, который расширяет ActionMenu действий, и мои контроллеры затем продлить этот класс!
вы уверены, что 'ActionMenu :: __ конструкт()' звонит 'parent :: __ construct()'? –