しかし、1.1のViewのコンストラクタにはこんなコードが入っていました。
function __construct(&$controller) {
if(is_object($controller)){
$this->controller =& $controller;
$this->_viewVars = $this->controller->_viewVars;
$this->action = $this->controller->action;
$this->autoLayout = $this->controller->autoLayout;
$this->autoRender = $this->controller->autoRender;
$this->base = $this->controller->base;
$this->webroot = $this->controller->webroot;
$this->helpers = $this->controller->helpers;
$this->here = $this->controller->here;
$this->layout = $this->controller->layout;
$this->modelNames = $this->controller->modelNames;
$this->name = $this->controller->name;
$this->pageTitle = $this->controller->pageTitle;
$this->viewPath = $this->controller->viewPath;
$this->params = $this->controller->params;
$this->data = $this->controller->data;
$this->webservices = $this->controller->webservices;
$this->plugin = $this->controller->plugin;
}
parent::__construct();
}
1.2では配列で設定されています。
var $__passedVars = array('viewVars', 'action', 'autoLayout', 'autoRender', 'ext', 'base', 'webroot', 'helpers', 'here', 'layout', 'name', 'pageTitle', 'layoutPath', 'viewPath', 'params', 'data', 'webservices', 'plugin', 'passedArgs', 'cacheAction');
$count = count($this->__passedVars);
for ($j = 0; $j < $count; $j++) {
$var = $this->__passedVars[$j];
$this->{$var} = $controller->{$var};
}
ViewのHTMLの中でも、かなりのデータにアクセスできます。うまく活用できるとなかなか便利ですね。