예제 #1
0
 public function testGetBlockAlias()
 {
     // Without layout
     $this->assertEmpty($this->_block->getBlockAlias());
     $this->assertInternalType('string', $this->_block->getBlockAlias());
     // Without alias
     $block1 = $this->_createBlockWithLayout('name1');
     $this->assertEquals('name1', $block1->getBlockAlias());
     // With alias
     $block2 = $this->_createBlockWithLayout('name2', 'alias');
     $this->assertEquals('alias', $block2->getBlockAlias());
     // Change block's alias while changing parent
     $blockParent = $this->_createBlockWithLayout('parent', 'parent');
     $blockChild = $this->_createBlockWithLayout('child', 'child');
     $this->assertEquals('child', $blockChild->getBlockAlias());
     $blockParent->setChild('parent_child', $blockChild);
     $this->assertEquals('parent_child', $blockChild->getBlockAlias());
 }
예제 #2
0
 /**
  * Get block information
  *
  * @param Mage_Core_Block_Abstract $block
  * @param bool $fullInfo
  * @return array
  */
 public function getBlockInfo(Mage_Core_Block_Abstract $block, $fullInfo = true)
 {
     $info = array('name' => $block->getNameInLayout(), 'alias' => $block->getBlockAlias());
     if (!$fullInfo) {
         return $info;
     }
     $info['class'] = get_class($block);
     if ($this->getRemoteCallEnabled()) {
         $fileAndLine = Mage::helper('aoe_templatehints/classInfo')->findFileAndLine($info['class']);
         if ($fileAndLine) {
             $url = sprintf($this->getRemoteCallUrlTemplate(), $fileAndLine['file'], $fileAndLine['line']);
             $info['class'] = sprintf($this->getRemoteCallLinkTemplate(), $url, $info['class']);
         }
     }
     $info['module'] = $block->getModuleName();
     if ($block instanceof Mage_Cms_Block_Block) {
         $info['cms-blockId'] = $block->getBlockId();
     }
     if ($block instanceof Mage_Cms_Block_Page) {
         $info['cms-pageId'] = $block->getPage()->getIdentifier();
     }
     $templateFile = $block->getTemplateFile();
     if ($templateFile) {
         $info['template'] = $templateFile;
         if ($this->getRemoteCallEnabled()) {
             $url = sprintf($this->getRemoteCallUrlTemplate(), Mage::getBaseDir('design') . DS . $templateFile, 0);
             $info['template'] = sprintf($this->getRemoteCallLinkTemplate(), $url, $templateFile);
         }
     }
     // cache information
     $info['cache-status'] = self::TYPE_NOTCACHED;
     $cacheLifeTime = $block->getCacheLifetime();
     if (!is_null($cacheLifeTime)) {
         $info['cache-lifetime'] = intval($cacheLifeTime) == 0 ? 'forever' : intval($cacheLifeTime) . ' sec';
         $info['cache-key'] = $block->getCacheKey();
         $info['cache-key-info'] = is_array($block->getCacheKeyInfo()) ? implode(', ', $block->getCacheKeyInfo()) : $block->getCacheKeyInfo();
         $info['tags'] = implode(',', $block->getCacheTags());
         $info['cache-status'] = self::TYPE_CACHED;
     } elseif ($this->isWithinCachedBlock($block)) {
         $info['cache-status'] = self::TYPE_IMPLICITLYCACHED;
         // not cached, but within cached
     }
     $info['methods'] = $this->getClassMethods(get_class($block));
     return $info;
 }
예제 #3
0
 /**
  * Make sure specified block will be registered in the specified child groups
  *
  * @param string $groupName
  * @param Mage_Core_Block_Abstract $child
  */
 public function addToChildGroup($groupName, Mage_Core_Block_Abstract $child)
 {
     if (!isset($this->_childGroups[$groupName])) {
         $this->_childGroups[$groupName] = array();
     }
     if (!in_array($child->getBlockAlias(), $this->_childGroups[$groupName])) {
         $this->_childGroups[$groupName][] = $child->getBlockAlias();
     }
 }
예제 #4
0
 public function testGetSetBlockAlias()
 {
     $this->assertEmpty($this->_block->getBlockAlias());
     $this->_block->setBlockAlias('alias');
     $this->assertEquals('alias', $this->_block->getBlockAlias());
 }