/** * Replace block content to placeholder replacer * * @param string $content * @return string */ public function replaceContentToPlaceholderReplacer($content) { $placeholders = array(); preg_match_all(Enterprise_PageCache_Model_Container_Placeholder::HTML_NAME_PATTERN, $content, $placeholders, PREG_PATTERN_ORDER); $placeholders = array_unique($placeholders[1]); try { foreach ($placeholders as $definition) { $this->_placeholder = Mage::getModel('enterprise_pagecache/container_placeholder', $definition); $content = preg_replace_callback($this->_placeholder->getPattern(), array($this, '_getPlaceholderReplacer'), $content); } $this->_placeholder = null; } catch (Exception $e) { $this->_placeholder = null; throw $e; } return $content; }
/** * Process Containers * * @param $content * @return array */ protected function _processContainers(&$content) { $placeholders = array(); preg_match_all(Enterprise_PageCache_Model_Container_Placeholder::HTML_NAME_PATTERN, $content, $placeholders, PREG_PATTERN_ORDER); $placeholders = array_unique($placeholders[1]); $containers = array(); foreach ($placeholders as $definition) { $placeholder = new Enterprise_PageCache_Model_Container_Placeholder($definition); $container = $placeholder->getContainerClass(); if (!$container) { continue; } $container = new $container($placeholder); $container->setProcessor($this); if (!$container->applyWithoutApp($content)) { $containers[] = $container; } else { preg_match($placeholder->getPattern(), $content, $matches); if (array_key_exists(1, $matches)) { $containers = array_merge($this->_processContainers($matches[1]), $containers); $content = preg_replace($placeholder->getPattern(), str_replace('$', '\\$', $matches[1]), $content); } } } return $containers; }