/**
  * Get Placeholder Block
  *
  * @return Mage_Core_Block_Abstract
  */
 protected function _getPlaceHolderBlock()
 {
     if (null === $this->_placeholderBlock) {
         $blockName = $this->_placeholder->getAttribute('block');
         $this->_placeholderBlock = new $blockName();
         $this->_placeholderBlock->setTemplate($this->_placeholder->getAttribute('template'));
         $this->_placeholderBlock->setLayout(Mage::app()->getLayout());
         $this->_placeholderBlock->setSkipRenderTag(true);
     }
     return $this->_placeholderBlock;
 }
Exemplo n.º 2
0
 public function testHelper()
 {
     // Without layout
     $this->assertInstanceOf('Mage_Core_Helper_Data', $this->_block->helper('Mage_Core_Helper_Data'));
     // With layout
     $this->_block->setLayout(new Mage_Core_Model_Layout());
     $helper = $this->_block->helper('Mage_Core_Helper_Data');
     try {
         $this->assertInstanceOf('Mage_Core_Helper_Data', $helper);
         $this->assertInstanceOf('Mage_Core_Model_Layout', $helper->getLayout());
         /* Helper is a 'singleton', so assigned layout may affect further helper usage */
         $helper->setLayout(null);
     } catch (Exception $e) {
         $helper->setLayout(null);
         throw $e;
     }
 }
Exemplo n.º 3
0
 /**
  * Create <N> sample blocks
  *
  * @param int $qty
  * @param bool $withLayout
  * @param string $className
  * @return array
  */
 protected function _createSampleBlocks($qty, $withLayout = true, $className = 'Mage_Core_Block_Template')
 {
     $blocks = array();
     $names = array();
     $layout = false;
     if ($withLayout) {
         $layout = new Mage_Core_Model_Layout();
         $this->_block->setLayout($layout);
     }
     for ($i = 0; $i < $qty; $i++) {
         $block = new $className();
         $name = uniqid('block.');
         $block->setNameInLayout($name);
         $blocks[] = $block;
         $names[] = $name;
         if ($layout) {
             $block->setLayout($layout);
             $layout->setBlock($name, $block);
         }
     }
     return array($blocks, $names);
 }