74 \
Magento\Framework\View\LayoutInterface $layout,
79 $this->_domFactory = $domFactory;
80 $this->_moduleReader = $moduleReader;
81 $this->_layout = $layout;
82 $this->_appState = $appState;
83 $this->_persistentFactory = $persistentFactory;
96 $this->_configFilePath =
$path;
106 protected function _getConfigDomXPath()
108 if ($this->_configDomXPath ===
null) {
109 $dir = explode(
"/", $this->_configFilePath);
111 $dir = implode(
"/", $dir);
112 $directoryRead = $this->readFactory->create($dir);
113 $filePath = $directoryRead->getRelativePath($this->_configFilePath);
114 $isFile = $directoryRead->isFile($filePath);
115 $isReadable = $directoryRead->isReadable($filePath);
116 if (!$isFile || !$isReadable) {
117 throw new \Magento\Framework\Exception\LocalizedException(
118 __(
'We cannot load the configuration from file %1.', $this->_configFilePath)
121 $xml = $directoryRead->readFile($filePath);
123 $configDom = $this->_domFactory->createDom(
126 'idAttributes' => [
'config/instances/blocks/reference' =>
'id'],
127 'schemaFile' => $this->_moduleReader->getModuleDir(
Dir::MODULE_ETC_DIR,
'Magento_Persistent')
131 $this->_configDomXPath = new \DOMXPath($configDom->getDom());
145 $xPath =
'//instances/blocks/*[block_type="' .
$block .
'"]';
146 $blocks = $this->_getConfigDomXPath()->query($xPath);
147 return $this->_convertBlocksToArray($blocks);
158 $xPath =
'/config/instances/blocks/reference';
159 $blocks = $this->_getConfigDomXPath()->query($xPath);
160 $blocksArray = $this->_convertBlocksToArray($blocks);
161 return [
'blocks' => $blocksArray];
170 protected function _convertBlocksToArray($blocks)
173 foreach ($blocks as $reference) {
174 $referenceAttributes = $reference->attributes;
175 $id = $referenceAttributes->getNamedItem(
'id')->nodeValue;
176 $blocksArray[
$id] = [];
178 foreach ($reference->childNodes as $referenceSubNode) {
179 switch ($referenceSubNode->nodeName) {
180 case 'name_in_layout':
184 $blocksArray[
$id][$referenceSubNode->nodeName] = $referenceSubNode->nodeValue;
201 if (!is_array($elements)) {
204 foreach ($elements as
$info) {
207 $this->
fireOne($info, $this->_layout->getBlock(
$info[
'name_in_layout']));
225 if (!$instance || isset(
227 ) && !$instance instanceof
$info[
'block_type'] || !isset(
235 $object = $this->_persistentFactory->create(
$info[
'class']);
238 if (method_exists($object,
$method)) {
241 throw new \Magento\Framework\Exception\LocalizedException(
242 __(
'Method "%1" is not defined in "%2"',
$method, get_class($object))
getBlockConfigInfo($block)
elseif(isset( $params[ 'redirect_parent']))
collectInstancesToEmulate()
fireOne($info, $instance=false)
__construct(\Magento\Framework\Config\DomFactory $domFactory, \Magento\Framework\Module\Dir\Reader $moduleReader, \Magento\Framework\View\LayoutInterface $layout, \Magento\Framework\App\State $appState, \Magento\Persistent\Model\Factory $persistentFactory, \Magento\Framework\Filesystem\Directory\ReadFactory $readFactory)
foreach( $_productCollection as $_product)() ?>" class $info