Skip to content

Commit 00d50de

Browse files
committed
Add accessor method for View::autoLayout
1 parent 28f459e commit 00d50de

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/Controller/Controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ public function render($view = null, $layout = null)
558558
}
559559

560560
if (!empty($this->request->params['bare'])) {
561-
$this->_view->autoLayout = false;
561+
$this->_view->autoLayout(false);
562562
}
563563

564564
$viewClass = $this->viewClass;

src/View/View.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -366,6 +366,23 @@ public function layoutPath($path = null)
366366
$this->layoutPath = $path;
367367
}
368368

369+
/**
370+
* Turns on or off CakePHP's conventional mode of applying layout files.
371+
* On by default. Setting to off means that layouts will not be
372+
* automatically applied to rendered views.
373+
*
374+
* @param string $autoLayout Boolean to turn on/off. If null returns current value.
375+
* @return bool|void
376+
*/
377+
public function autoLayout(bool $autoLayout = null)
378+
{
379+
if ($var === null) {
380+
return $this->autoLayout;
381+
}
382+
383+
$this->layoutPath = $autoLayout;
384+
}
385+
369386
/**
370387
* Renders a piece of PHP with provided parameters and returns HTML, XML, or any other string.
371388
*

0 commit comments

Comments
 (0)