Skip to content
Permalink
Browse files

Add ViewBuilder::disableAutoLayout().

  • Loading branch information...
ADmad committed Nov 1, 2018
1 parent bc8c37f commit 1a91ee75a5c2d0689c950f158275fa1b983d8297
Showing with 30 additions and 1 deletion.
  1. +1 −1 src/Controller/Controller.php
  2. +15 −0 src/View/ViewBuilder.php
  3. +14 −0 tests/TestCase/View/ViewBuilderTest.php
@@ -771,7 +771,7 @@ public function render($view = null, $layout = null)
}
if ($this->request->getParam('bare')) {
$builder->enableAutoLayout(false);
$builder->disableAutoLayout();
}
$this->autoRender = false;
@@ -279,6 +279,21 @@ public function enableAutoLayout($enable = true)
return $this;
}
/**
* Turns off CakePHP's conventional mode of applying layout files.
*
* Setting to off means that layouts will not be automatically applied to
* rendered views.
*
* @return $this
*/
public function disableAutoLayout()
{
$this->_autoLayout = false;
return $this;
}
/**
* Returns if CakePHP's conventional mode of applying layout files is enabled.
* Disabled means that layouts will not be automatically applied to rendered views.
@@ -397,4 +397,18 @@ public function testCreateFromArray()
$this->assertEquals(['Html'], $builder->getHelpers());
$this->assertEquals('JsonView', $builder->getClassName());
}
/**
* testDisableAutoLayout
*
* @return void
*/
public function testDisableAutoLayout()
{
$builder = new ViewBuilder();
$this->assertNull($builder->isAutoLayoutEnabled());
$builder->disableAutoLayout();
$this->assertFalse($builder->isAutoLayoutEnabled());
}
}

0 comments on commit 1a91ee7

Please sign in to comment.
You can’t perform that action at this time.