/** * Creates block object based on xml node data and add it to the layout * * @param string $elementName * @return Mage_Core_Block_Abstract * @throws Magento_Exception */ protected function _generateBlock($elementName) { list($type, $node, $actions, $arguments) = $this->_scheduledStructure->getElement($elementName); if ($type !== self::TYPE_BLOCK) { throw new Magento_Exception("Unexpected element type specified for generating block: {$type}."); } // create block if (!empty($node['class'])) { $className = (string) $node['class']; } else { $className = (string) $node['type']; } $arguments = $this->_argumentProcessor->process($arguments); $block = $this->_createBlock($className, $elementName, $arguments); if (!empty($node['template'])) { $block->setTemplate((string) $node['template']); } $this->_scheduledStructure->unsetElement($elementName); // execute block methods foreach ($actions as $action) { list($actionNode, $parent) = $action; $this->_generateAction($actionNode, $parent); } return $block; }
/** * @covers Mage_Core_Model_Layout_ScheduledStructure::unsetElement */ public function testUnsetElement() { $this->assertTrue($this->_model->hasElement('element1')); $this->_model->unsetElement('element1'); $this->assertFalse($this->_model->hasElement('element1')); }