当前位置: 首页>>代码示例>>PHP>>正文


PHP Mage_Core_Block_Abstract::getData方法代码示例

本文整理汇总了PHP中Mage_Core_Block_Abstract::getData方法的典型用法代码示例。如果您正苦于以下问题:PHP Mage_Core_Block_Abstract::getData方法的具体用法?PHP Mage_Core_Block_Abstract::getData怎么用?PHP Mage_Core_Block_Abstract::getData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mage_Core_Block_Abstract的用法示例。


在下文中一共展示了Mage_Core_Block_Abstract::getData方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getBlockKey

 /**
  * Get the final block key used for caching
  *
  * @param Mage_Core_Block_Abstract $block
  * @return string
  */
 public function getBlockKey(Mage_Core_Block_Abstract $block)
 {
     $cacheKeys = array_values($block->getData('cache_keys'));
     $key = implode('|', $cacheKeys);
     $key = sha1($key);
     return $key;
 }
开发者ID:eneiasramos,项目名称:Made_Cache,代码行数:13,代码来源:Data.php

示例2: _getCacheKey

 /**
  * Get Key for caching block content
  *
  * @see Mage_Core_Block_Abstract
  * @return string
  */
 protected function _getCacheKey(array $keyInfo, Mage_Core_Block_Abstract $block = null)
 {
     if ($block !== null) {
         $cacheKey = $block->getData('cache_key');
         if (!empty($cacheKey)) {
             $keyInfo = array($cacheKey);
         } else {
             $keyInfo = array_values($keyInfo);
         }
     }
     $key = implode('|', $keyInfo);
     $key = sha1($key);
     return $key;
 }
开发者ID:finelinePG,项目名称:finelink-dev,代码行数:20,代码来源:Abstract.php

示例3: applyCacheSettings


//.........这里部分代码省略.........
                 }
             }
         }
     }
     if (false === $blockGroup) {
         // It is a block group we don't change caching for.
         return;
     }
     $cacheLifeTime = null;
     if (Mage::getStoreConfigFlag(self::CONFIG_SECTION . '/' . $blockGroup . '/enable_cache')) {
         $cacheLifeTime = intval(Mage::getStoreConfig(self::CONFIG_SECTION . '/' . $blockGroup . '/lifetime'));
     }
     /** @noinspection PhpUndefinedMethodInspection */
     $block->setCacheLifetime($cacheLifeTime);
     if ($cacheLifeTime) {
         $currentCategory = null;
         $currentProduct = null;
         $cacheKey = self::CACHEKEY_START;
         $cacheKeyData = '';
         $cacheTags = array();
         switch ($blockGroup) {
             case self::BLOCK_GROUP_CATEGORY:
                 $cacheKey .= self::CACHEKEY_GROUP_CATEGORY;
                 $currentCategory = Mage::registry('current_category');
                 // Add sorting & paging to cache key
                 $catalogSession = Mage::getSingleton('catalog/session');
                 if ($catalogSession) {
                     /** @noinspection PhpUndefinedMethodInspection */
                     $cacheKeyData .= '|so' . strval($catalogSession->getSortOrder());
                     /** @noinspection PhpUndefinedMethodInspection */
                     $cacheKeyData .= '|sd' . strval($catalogSession->getSortDirection());
                     /** @noinspection PhpUndefinedMethodInspection */
                     $cacheKeyData .= '|dm' . strval($catalogSession->getDisplayMode());
                     /** @noinspection PhpUndefinedMethodInspection */
                     $cacheKeyData .= '|lp' . strval($catalogSession->getLimitPage());
                 }
                 break;
             case self::BLOCK_GROUP_PRODUCT:
                 $cacheKey .= self::CACHEKEY_GROUP_PRODUCT;
                 $currentCategory = Mage::registry('current_category');
                 $currentProduct = Mage::registry('current_product');
                 break;
             case self::BLOCK_GROUP_LAYERED_NAV:
                 $cacheKey .= self::CACHEKEY_GROUP_LAYERED_NAV;
                 $currentCategory = Mage::registry('current_category');
                 break;
             case self::BLOCK_GROUP_CMS_PAGE:
                 $cacheKey .= self::CACHEKEY_GROUP_CMS_PAGE;
                 $cmsPage = Mage::getSingleton('cms/page');
                 if ($cmsPage instanceof Mage_Cms_Model_Page) {
                     $cacheTags[] = Mage_Cms_Model_Page::CACHE_TAG . '_' . $cmsPage->getId();
                     $cacheKey .= 'P' . $cmsPage->getId() . '_';
                 }
                 break;
             case self::BLOCK_GROUP_CMS_BLOCK:
                 /** @noinspection PhpUndefinedMethodInspection */
                 $cacheKey .= self::CACHEKEY_GROUP_CMS_BLOCK;
                 $cacheKeyData .= '|b' . $block->getBlockId();
                 // Example block_id: 'after_body_start'
                 $cacheTags[] = Mage_Cms_Model_Block::CACHE_TAG;
                 break;
             case self::BLOCK_GROUP_CUSTOM_1:
             case self::BLOCK_GROUP_CUSTOM_2:
             case self::BLOCK_GROUP_CUSTOM_3:
             case self::BLOCK_GROUP_CUSTOM_4:
             case self::BLOCK_GROUP_CUSTOM_5:
                 /** @noinspection PhpUndefinedMethodInspection */
                 // We don't know what it exactly is the user configured, so we throw everything in
                 $cacheKey .= constant('self::CACHEKEY_GROUP_' . strtoupper($blockGroup));
                 $currentCategory = Mage::registry('current_category');
                 $currentProduct = Mage::registry('current_product');
                 $allData = $block->getData();
                 unset($allData['cache_lifetime']);
                 $cacheKeyData .= '|D' . json_encode($allData, 0, 3);
                 // All block data, 3 levels max
                 break;
             default:
                 Mage::log("ERROR: %s->%s: Unknown block group '%s'", __CLASS__, __FUNCTION__, $blockGroup);
         }
         if ($currentCategory instanceof Mage_Catalog_Model_Category) {
             $cacheKey .= 'C' . $currentCategory->getId();
         }
         if ($currentProduct instanceof Mage_Catalog_Model_Product) {
             $cacheKey .= 'P' . $currentProduct->getId();
         }
         $cacheKeyData .= $this->getBlockCacheKeyData($block, $store, $currentCategory, $currentProduct);
         $cacheKey .= '_' . md5($cacheKeyData);
         $this->addBlockCacheTags($cacheTags, $currentCategory, $currentProduct);
         $cacheTags = array_unique($cacheTags);
         /** @noinspection PhpUndefinedMethodInspection */
         $block->setCacheKey($cacheKey);
         /** @noinspection PhpUndefinedMethodInspection */
         $block->setCacheTags($cacheTags);
         if (Mage::getStoreConfigFlag(self::CONFIG_SECTION . '/logging/tags')) {
             $message = sprintf('Block %s Tags %s', $cacheKey, $this->logTags($cacheTags));
             $message .= $this->getLogSuffix();
             Mage::log($message, Zend_Log::INFO, self::TAGS_LOG_FILE);
         }
     }
 }
开发者ID:Hevelop,项目名称:jeroenvermeulen-blockcache,代码行数:101,代码来源:Observer.php

示例4: testGetModuleName

 public function testGetModuleName()
 {
     $this->assertEquals('Mage_Core', $this->_block->getModuleName());
     $this->assertEquals('Mage_Core', $this->_block->getData('module_name'));
 }
开发者ID:nemphys,项目名称:magento2,代码行数:5,代码来源:AbstractTest.php


注:本文中的Mage_Core_Block_Abstract::getData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。