本文整理汇总了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;
}
示例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;
}
示例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);
}
}
}
示例4: testGetModuleName
public function testGetModuleName()
{
$this->assertEquals('Mage_Core', $this->_block->getModuleName());
$this->assertEquals('Mage_Core', $this->_block->getData('module_name'));
}