From 7b54ff897dcf5fcd8654814d109c15f67acb6d38 Mon Sep 17 00:00:00 2001 From: ADmad Date: Thu, 1 Nov 2018 19:46:17 +0530 Subject: [PATCH] Add View::disableAutoLayout(). --- src/View/View.php | 14 ++++++++++++++ tests/TestCase/View/ViewTest.php | 17 +++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/src/View/View.php b/src/View/View.php index cf6661de297..6e004c669b9 100644 --- a/src/View/View.php +++ b/src/View/View.php @@ -563,6 +563,20 @@ public function enableAutoLayout($enable = true) return $this; } + /** + * Turns off CakePHP's conventional mode of applying layout files. + + * Layouts will not be automatically applied to rendered views. + * + * @return $this + */ + public function disableAutoLayout() + { + $this->autoLayout = false; + + return $this; + } + /** * Turns on or off CakePHP's conventional mode of applying layout files. * On by default. Setting to off means that layouts will not be diff --git a/tests/TestCase/View/ViewTest.php b/tests/TestCase/View/ViewTest.php index 2a583d97867..f51a2d63109 100644 --- a/tests/TestCase/View/ViewTest.php +++ b/tests/TestCase/View/ViewTest.php @@ -2093,6 +2093,23 @@ public function testAutoLayout() $this->assertSame($autoLayout, true); } + + /** + * testDisableAutoLayout + * + * @return void + */ + public function testDisableAutoLayout() + { + $this->assertTrue($this->View->isAutoLayoutEnabled()); + + $result = $this->View->disableAutoLayout(); + $this->assertSame($this->View, $result); + + $autoLayout = $this->View->isAutoLayoutEnabled(); + $this->assertFalse($this->View->isAutoLayoutEnabled()); + } + /** * Test getTheme() and setTheme(). *