本文整理汇总了PHP中Mage_Core_Model_Layout::generateXml方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Model_Layout::generateXml方法的具体用法?PHP Mage_Core_Model_Layout::generateXml怎么用?PHP Mage_Core_Model_Layout::generateXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mage_Core_Model_Layout
的用法示例。
在下文中一共展示了Mage_Core_Model_Layout::generateXml方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
protected function setUp()
{
$this->_layout = Mage::getModel('Mage_Core_Model_Layout', array('area' => 'adminhtml'));
$this->_layout->getUpdate()->load('layout_test_grid_handle');
$this->_layout->generateXml();
$this->_layout->generateElements();
$this->_block = $this->_layout->getBlock('admin.test.grid.massaction');
}
示例2: getBlock
/**
* Get block
*
* @param string $blockName
* @return Mage_Core_Block_Abstract
*/
public function getBlock($blockName)
{
/** @var $layout Mage_Core_Model_Layouts */
$this->_prepareLayout();
$this->_layout->getUpdate()->load($this->_getHandles());
$this->_layout->generateXml()->generateBlocks();
$block = $this->_layout->getBlock($blockName);
$this->unsetLayout();
return $block;
}
示例3: testLayoutObjectArgumentUpdatersDirective
public function testLayoutObjectArgumentUpdatersDirective()
{
$layout = new Mage_Core_Model_Layout();
$layout->getUpdate()->load(array('layout_test_handle_arguments_object_type_updaters'));
$layout->generateXml()->generateElements();
$expectedObjectData = array(0 => 'updater call', 1 => 'updater call', 2 => 'updater call');
$expectedSimpleData = 2;
$block = $layout->getBlock('block_with_object_updater_args')->getOne();
$this->assertInstanceOf('Mage_Core_Block_Text', $block);
$this->assertEquals($expectedObjectData, $block->getUpdaterCall());
$this->assertEquals($expectedSimpleData, $layout->getBlock('block_with_object_updater_args')->getTwo());
}
示例4: testGenerateXmlAndBlocks
/**
* @covers Mage_Core_Model_Layout::getAllBlocks
* @covers Mage_Core_Model_Layout::generateBlocks
* @covers Mage_Core_Model_Layout::getBlock
*/
public function testGenerateXmlAndBlocks()
{
$this->_model->generateXml();
/* Generate fixture
file_put_contents(__DIR__ . '/_files/_layout_update.xml', $this->_model->getNode()->asNiceXml());
*/
$this->assertXmlStringEqualsXmlFile(__DIR__ . '/_files/_layout_update.xml', $this->_model->getXmlString());
$this->assertEquals(array(), $this->_model->getAllBlocks());
$expectedBlocks = array('root', 'head', 'head.calendar', 'notifications', 'notification_baseurl', 'cache_notifications', 'notification_survey', 'notification_security', 'messages', 'index_notifications', 'index_notifications_copy');
$this->_model->generateBlocks();
$actualBlocks = $this->_model->getAllBlocks();
$this->assertEquals($expectedBlocks, array_keys($actualBlocks));
/** @var $block Mage_Adminhtml_Block_Page_Head */
$block = $this->_model->getBlock('head');
$this->assertEquals('Magento Admin', $block->getTitle());
$block = $this->_model->getBlock('head.calendar');
$this->assertSame($this->_model->getBlock('head'), $block->getParentBlock());
/** @var $block Mage_Core_Block_Template */
$block = $this->_model->getBlock('root');
$this->assertEquals('popup.phtml', $block->getTemplate());
}
示例5: generateXml
/**
* Take cache/noache/ESI tags into concern for block rendering
*
* @return Mage_Core_Model_Layout
*/
public function generateXml()
{
parent::generateXml();
$xml = $this->getNode();
// Find blocks to cache
$cacheList = $xml->xpath("//cache/*");
if (count($cacheList)) {
foreach ($cacheList as $node) {
$lifetime = (int) $node->getAttribute('lifetime');
if (empty($lifetime)) {
$lifetime = self::DEFAULT_CACHE_LIFETIME;
}
$modifiers = trim((string) $node->getAttribute('modifiers'));
$key = (string) $node->getAttribute('key');
$this->_cacheBlocks[(string) $node] = array('lifetime' => $lifetime, 'key' => $key, 'modifiers' => $modifiers);
}
}
// Find eventual nocache tags
$noCacheList = $xml->xpath("//nocache/*");
if (count($noCacheList)) {
foreach ($noCacheList as $node) {
$blockName = trim((string) $node);
if (isset($this->_cacheBlocks[$blockName])) {
unset($this->_cacheBlocks[$blockName]);
}
}
}
// Find blocks that should be represented by ESI tags
$esiList = $xml->xpath("//esi/*");
if (count($esiList)) {
foreach ($esiList as $node) {
$blockName = trim((string) $node);
// Names are unique, an array could hold future settings
$unique = trim((string) $node->getAttribute('unique'));
$this->_esiBlocks[$blockName] = array('unique' => $unique);
}
}
// Find eventual noesi tags
$noEsiList = $xml->xpath("//noesi/*");
if (count($noEsiList)) {
foreach ($noEsiList as $node) {
$blockName = trim((string) $node);
// Names are unique, an array could hold future settings
if (isset($this->_esiBlocks[$blockName])) {
unset($this->_esiBlocks[$blockName]);
}
}
}
return $this;
}
示例6: _generateBlockLayoutXML
protected function _generateBlockLayoutXML($blockName)
{
if (self::$_layoutXml == null) {
self::$_layoutXml = Mage::app()->getLayout()->getUpdate()->asSimplexml();
}
$sections = self::$_layoutXml->xpath("//block[@name='{$blockName}'] | //reference[@name='{$blockName}']");
$layoutXml = '';
foreach ($sections as $section) {
$layoutXml .= $this->_generateSubBlockLayoutXml($section);
}
$layout = new Mage_Core_Model_Layout();
$layout->getUpdate()->addUpdate($layoutXml);
$layout->generateXml();
$layoutXml = $layout->getXmlString();
return $layoutXml;
}
示例7: generateXml
/**
* Records information about blocks removal and loaded layout handles
* (non-PHPdoc)
* @see Mage_Core_Model_Layout::generateXml()
*/
public function generateXml()
{
$loadedHandles = $this->getUpdate()->getHandles();
foreach ($loadedHandles as $key => $handle) {
$params = array();
if ($key > 0) {
$params['after'] = array_slice($loadedHandles, 0, $key);
} else {
$params['after'] = array();
}
if ($key < count($loadedHandles)) {
$params['before'] = array_slice($loadedHandles, $key + 1);
} else {
$params['before'] = array();
}
$this->record(self::ACTION_HANDLE_LOADED, $handle, $params);
}
parent::generateXml();
$removedBlocks = $this->_xml->xpath('//block[@ignore]');
if (is_array($removedBlocks)) {
foreach ($removedBlocks as $block) {
$this->record(self::ACTION_BLOCK_REMOVED, $block->getBlockName());
}
}
return $this;
}
示例8: testGenerateElementsBroken
/**
* @expectedException Magento_Exception
*/
public function testGenerateElementsBroken()
{
$layout = new Mage_Core_Model_Layout();
$layout->getUpdate()->load('layout_test_handle_remove_broken');
$layout->generateXml()->generateElements();
}