/** * {@inheritdoc} */ public function loadLayout($handles = null, $generateBlocks = true, $generateXml = true, $addActionHandles = true) { if ($this->_isLayoutLoaded) { throw new \RuntimeException('Layout must be loaded only once.'); } // if handles were specified in arguments load them first if (!empty($handles)) { $this->getLayout()->getUpdate()->addHandle($handles); } if ($addActionHandles) { // add default layout handles for this action $this->page->initLayout(); } $this->loadLayoutUpdates(); if (!$generateXml) { return $this; } $this->generateLayoutXml(); if (!$generateBlocks) { return $this; } $this->generateLayoutBlocks(); $this->_isLayoutLoaded = true; return $this; }
/** * {@inheritdoc} */ public function initLayout() { $pluginInfo = $this->pluginList->getNext($this->subjectType, 'initLayout'); if (!$pluginInfo) { return parent::initLayout(); } else { return $this->___callPlugins('initLayout', func_get_args(), $pluginInfo); } }
public function testInitLayoutLayoutDefined() { $handleDefault = 'default'; $fullActionName = 'full_action_name'; $this->request->expects($this->any())->method('getFullActionName')->will($this->returnValue($fullActionName)); $this->layoutMerge->expects($this->at(0))->method('addHandle')->with($handleDefault)->willReturnSelf(); $this->layoutMerge->expects($this->at(1))->method('addHandle')->with($fullActionName)->willReturnSelf(); $this->layoutMerge->expects($this->at(2))->method('isLayoutDefined')->willReturn(true); $this->layoutMerge->expects($this->at(3))->method('removeHandle')->with($handleDefault)->willReturnSelf(); $this->assertEquals($this->page, $this->page->initLayout()); }