diff --git a/src/Controller/Component/RequestHandlerComponent.php b/src/Controller/Component/RequestHandlerComponent.php index f219a484f44..eca61c7f2fb 100644 --- a/src/Controller/Component/RequestHandlerComponent.php +++ b/src/Controller/Component/RequestHandlerComponent.php @@ -108,7 +108,7 @@ class RequestHandlerComponent extends Component { */ protected $_viewClassMap = array( 'json' => 'Json', - 'xml' => 'Xml', + 'xml' => 'Xml', 'ajax' => 'Ajax' ); @@ -142,7 +142,7 @@ public function initialize(Event $event) { if (isset($this->request->params['_ext'])) { $this->ext = $this->request->params['_ext']; } - if(empty($this->ext) && $this->request->is('ajax')) { + if (empty($this->ext) && $this->request->is('ajax')) { $this->ext = 'ajax'; } if (empty($this->ext) || in_array($this->ext, array('html', 'htm'))) { @@ -518,17 +518,20 @@ public function renderAs(Controller $controller, $type, array $options = array() if ($viewClass) { $controller->viewClass = $viewClass; - } elseif (empty($this->_renderType)) { - $controller->viewPath .= DS . $type; } else { - $controller->viewPath = preg_replace( - "/([\/\\\\]{$this->_renderType})$/", - DS . $type, - $controller->viewPath - ); - } - $this->_renderType = $type; - $controller->layoutPath = $type; + if (empty($this->_renderType)) { + $controller->viewPath .= DS . $type; + } else { + $controller->viewPath = preg_replace( + "/([\/\\\\]{$this->_renderType})$/", + DS . $type, + $controller->viewPath + ); + } + + $this->_renderType = $type; + $controller->layoutPath = $type; + } if ($this->response->getMimeType($type)) { $this->respondAs($type, $options); diff --git a/src/View/JsonView.php b/src/View/JsonView.php index 63da039f896..acfb4c4680a 100644 --- a/src/View/JsonView.php +++ b/src/View/JsonView.php @@ -56,8 +56,13 @@ class JsonView extends View { /** - * JSON views are always located in the 'json' sub directory for - * controllers' views. + * JSON layouts are always located in the json sub directory of `Layouts/` + * + */ + public $layoutPath = 'json'; + +/** + * JSON views are always located in the 'json' sub directory for controllers' views. * * @var string */ diff --git a/src/View/XmlView.php b/src/View/XmlView.php index 42dc7060c62..0c57cb99aa5 100644 --- a/src/View/XmlView.php +++ b/src/View/XmlView.php @@ -57,7 +57,13 @@ class XmlView extends View { /** - * The subdirectory. XML views are always in xml. + * XML layouts are always located in the xml sub directory of `Layouts/` + * + */ + public $layoutPath = 'xml'; + +/** + * XML views are always located in the 'xml' sub directory for controllers' views. * * @var string */