diff --git a/src/View/Cell.php b/src/View/Cell.php index c6f83355955..a0e356c945a 100644 --- a/src/View/Cell.php +++ b/src/View/Cell.php @@ -173,7 +173,7 @@ public function render($template = null) $render = function () use ($template) { $className = substr(strrchr(get_class($this), "\\"), 1); $name = substr($className, 0, -4); - $this->View->viewPath('Cell' . DS . $name); + $this->View->templatePath('Cell' . DS . $name); try { return $this->View->render($template); diff --git a/src/View/View.php b/src/View/View.php index 6c6549d7d7c..fdc2151f149 100644 --- a/src/View/View.php +++ b/src/View/View.php @@ -111,19 +111,19 @@ class View implements EventDispatcherInterface public $helpers = []; /** - * The name of the views subfolder containing views for this View. + * The name of the subfolder containing templates for this View. * * @var string */ - public $viewPath = null; + public $templatePath = null; /** - * The name of the view file to render. The name specified + * The name of the template file to render. The name specified * is the filename in /app/Template/ without the .ctp extension. * * @var string */ - public $view = null; + public $template = null; /** * The name of the layout file to render the view inside of. The name specified @@ -339,18 +339,18 @@ public function initialize() } /** - * Get/set path for view files. + * Get/set path for templates files. * - * @param string $path Path for view files. If null returns current path. + * @param string $path Path for template files. If null returns current path. * @return string|void */ - public function viewPath($path = null) + public function templatePath($path = null) { if ($path === null) { - return $this->viewPath; + return $this->templatePath; } - $this->viewPath = $path; + $this->templatePath = $path; } /** @@ -401,19 +401,19 @@ public function theme($theme = null) } /** - * Get/set the name of the view file to render. The name specified is the + * Get/set the name of the template file to render. The name specified is the * filename in /app/Template/ without the .ctp extension. * - * @param string $name View file name to set. If null returns current name. + * @param string $name Template file name to set. If null returns current name. * @return string|void */ - public function view($name = null) + public function template($name = null) { if ($name === null) { - return $this->view; + return $this->template; } - $this->view = $name; + $this->template = $name; } /** @@ -598,7 +598,7 @@ public function renderLayout($content, $layout = null) $title = $this->Blocks->get('title'); if ($title === '') { - $title = Inflector::humanize($this->viewPath); + $title = Inflector::humanize($this->templatePath); $this->Blocks->set('title', $title); } @@ -837,6 +837,13 @@ public function getCurrentType() */ public function __get($name) { + if ($name === 'view') { + return $this->template; + } + if ($name === 'viewPath') { + return $this->templatePath; + } + $registry = $this->helpers(); if (isset($registry->{$name})) { $this->{$name} = $registry->{$name}; @@ -845,6 +852,26 @@ public function __get($name) return $this->{$name}; } + /** + * Magic setter for deprecated properties. + * + * @param string $name Name to property. + * @param mixed $value Value for property. + */ + public function __set($name, $value) + { + if ($name === 'view') { + $this->template = $value; + return; + } + if ($name === 'viewPath') { + $this->templatePath = $value; + return; + } + + $this->{$name} = $value; + } + /** * Interact with the HelperRegistry to load all the helpers. * @@ -971,12 +998,12 @@ protected function _getViewFileName($name = null) if ($this->subDir !== null) { $subDir = $this->subDir . DS; } - if ($this->viewPath) { - $viewPath = $this->viewPath . DS; + if ($this->templatePath) { + $viewPath = $this->templatePath . DS; } if ($name === null) { - $name = $this->view; + $name = $this->template; } list($plugin, $name) = $this->pluginSplit($name); @@ -990,7 +1017,7 @@ protected function _getViewFileName($name = null) return $name; } $name = trim($name, DS); - } elseif (!$plugin || $this->viewPath !== $this->name) { + } elseif (!$plugin || $this->templatePath !== $this->name) { $name = $viewPath . $subDir . $name; } else { $name = DS . $subDir . $name;