16 use Psr\Log\LoggerInterface as Logger;
206 $this->_elementClass = \Magento\Framework\View\Layout\Element::class;
207 $this->_renderingOutput = new \Magento\Framework\DataObject();
211 $this->_eventManager = $eventManager;
252 if (!empty($this->builder)) {
253 $this->builder->build();
274 if (isset($this->_update) && is_object($this->_update)) {
275 $this->_update->__destruct();
276 $this->_update =
null;
279 parent::__destruct();
289 if (!$this->_update) {
290 $theme = $this->themeResolver->get();
291 $this->_update = $this->_processorFactory->create([
'theme' =>
$theme]);
303 $xml = $this->
getUpdate()->asSimplexml();
305 $this->structure->importElements([]);
316 \Magento\Framework\Profiler::start(__CLASS__ .
'::' . __METHOD__);
317 $cacheId =
'structure_' . $this->
getUpdate()->getCacheId();
318 $result = $this->cache->load($cacheId);
321 $this->
getReaderContext()->getPageConfigStructure()->populateWithArray(
$data[
'pageConfigStructure']);
324 \Magento\Framework\Profiler::start(
'build_structure');
326 \Magento\Framework\Profiler::stop(
'build_structure');
329 'pageConfigStructure' => $this->
getReaderContext()->getPageConfigStructure()->__toArray(),
330 'scheduledStructure' => $this->
getReaderContext()->getScheduledStructure()->__toArray(),
332 $this->cache->save($this->serializer->serialize(
$data), $cacheId, $this->
getUpdate()->getHandles());
335 $generatorContext = $this->generatorContextFactory->create(
337 'structure' => $this->structure,
342 \Magento\Framework\Profiler::start(
'generate_elements');
343 $this->generatorPool->process($this->
getReaderContext(), $generatorContext);
344 \Magento\Framework\Profiler::stop(
'generate_elements');
347 \Magento\Framework\Profiler::stop(__CLASS__ .
'::' . __METHOD__);
357 foreach ($this->structure->exportElements() as
$name =>
$element) {
375 $name = $this->structure->getChildId($parentName,
$alias);
410 public function reorderChild($parentName, $childName, $offsetOrSibling, $after =
true)
413 $this->structure->reorderChildElement($parentName, $childName, $offsetOrSibling, $after);
426 $this->structure->unsetChild($parentName,
$alias);
439 return array_keys($this->structure->getChildren($parentName));
454 foreach ($this->structure->getChildren($parentName) as $childName =>
$alias) {
473 return $this->structure->getChildId($parentName,
$alias);
486 if (!isset($this->_renderElementCache[
$name]) || !$useCache) {
490 return $this->_renderElementCache[
$name] =
'';
493 $this->_renderingOutput->setData(
'output', $this->_renderElementCache[
$name]);
494 $this->_eventManager->dispatch(
495 'core_layout_render_element',
496 [
'element_name' =>
$name,
'layout' => $this,
'transport' => $this->_renderingOutput]
498 return $this->_renderingOutput->getData(
'output');
511 $display = $this->structure->getAttribute(
$name,
'display');
512 if ($display ===
'' || $display ===
false || $display ===
null 513 || filter_var($display, FILTER_VALIDATE_BOOLEAN)) {
537 }
catch (\Exception $e) {
538 if ($this->appState->getMode() === AppState::MODE_DEVELOPER) {
570 return $uiComponent ? $uiComponent->toHtml() :
'';
593 $htmlId =
' id="' . $htmlId .
'"';
598 $htmlClass =
' class="' . $htmlClass .
'"';
603 $html = sprintf(
'<%1$s%2$s%3$s>%4$s</%1$s>', $htmlTag, $htmlId, $htmlClass, $html);
618 return $this->structure->addToParentGroup($blockName, $parentGroupName);
631 return $this->structure->getGroupChildNames($blockName, $groupName);
643 return $this->structure->hasElement(
$name);
668 if ($this->structure->hasElement(
$name)) {
683 if ($this->structure->hasElement(
$name)) {
698 if ($this->structure->hasElement(
$name)) {
713 $parentName = $this->structure->getParentId(
$name);
714 return $parentName && $this->
isContainer($parentName);
739 if (isset($this->_blocks[
$name])) {
740 $this->_blocks[
$name] =
null;
741 unset($this->_blocks[
$name]);
743 $this->structure->unsetElement(
$name);
775 $blockGenerator = $this->generatorPool->getGenerator(
Layout\Generator\Block::TYPE);
798 $name = $this->structure->createStructuralElement(
806 $this->structure->setAsChild(
$name, $parent,
$alias);
828 $containerGenerator = $this->generatorPool->getGenerator(
Layout\Generator\Container::TYPE);
829 $containerGenerator->generateContainer($this->structure,
$name,
$options);
831 $this->structure->setAsChild(
$name, $parent,
$alias);
845 if (isset($this->_blocks[$oldName])) {
846 $block = $this->_blocks[$oldName];
847 $this->_blocks[$oldName] =
null;
848 unset($this->_blocks[$oldName]);
849 $this->_blocks[$newName] =
$block;
851 $this->structure->renameElement($oldName, $newName);
876 if (isset($this->_blocks[
$name])) {
877 return $this->_blocks[
$name];
903 return $this->structure->getParentId($childName);
915 return $this->structure->getChildAlias($this->structure->getParentId(
$name),
$name);
938 if (isset($this->_output[
$name])) {
939 unset($this->_output[
$name]);
953 foreach ($this->_output as
$name) {
984 throw new \Magento\Framework\Exception\LocalizedException(
988 if (!isset($this->sharedBlocks[
$type])) {
991 return $this->sharedBlocks[
$type];
1005 $this->_renderers[$namespace][$staticType][$dynamicType] = [
1021 if (!isset($this->_renderers[$namespace])) {
1024 if (!isset($this->_renderers[$namespace][$staticType])) {
1027 if (!isset($this->_renderers[$namespace][$staticType][$dynamicType])) {
1030 return $this->_renderers[$namespace][$staticType][$dynamicType];
1040 public function executeRenderer($namespace, $staticType, $dynamicType,
$data = [])
1048 ->assign($dictionary)
1049 ->setTemplate(
$options[
'template'])
1068 $block->addMessages($this->messageManager->getMessages(
true,
$group));
1081 if (!is_array($messageGroups)) {
1082 $messageGroups = [$messageGroups];
1083 }
elseif (empty($messageGroups)) {
1084 $messageGroups[] = $this->messageManager->getDefaultGroup();
1086 return $messageGroups;
1098 return $this->cacheable && $cacheableXml;
1131 $this->
setXml(simplexml_load_string(self::LAYOUT_NODE, $this->_elementClass));
1143 if (!$this->readerContext) {
1144 $this->readerContext = $this->readerContextFactory->create();
getChildName($parentName, $alias)
const CONTAINER_OPT_HTML_ID
setBuilder(Layout\BuilderInterface $builder)
elseif(isset( $params[ 'redirect_parent']))
unsetChild($parentName, $alias)
_renderUiComponent($name)
getRendererOptions($namespace, $staticType, $dynamicType)
const CONTAINER_OPT_HTML_TAG
renameElement($oldName, $newName)
_renderContainer($name, $useCache=true)
isManipulationAllowed($name)
getChildBlock($parentName, $alias)
getParentName($childName)
initMessages($messageGroups=[])
renderElement($name, $useCache=true)
addContainer($name, $label, array $options=[], $parent='', $alias='')
getChildNames($parentName)
addAdjustableRenderer($namespace, $staticType, $dynamicType, $type, $template, $data=[])
getGroupChildNames($blockName, $groupName)
addToParentGroup($blockName, $parentGroupName)
createBlock($type, $name='', array $arguments=[])
getElementProperty($name, $attribute)
removeOutputElement($name)
const CONTAINER_OPT_HTML_CLASS
setChild($parentName, $elementName, $alias)
reorderChild($parentName, $childName, $offsetOrSibling, $after=true)
addBlock($block, $name='', $parent='', $alias='')
_prepareMessageGroup($messageGroups)
getChildBlocks($parentName)
__construct(Layout\ProcessorFactory $processorFactory, ManagerInterface $eventManager, Layout\Data\Structure $structure, MessageManagerInterface $messageManager, Design\Theme\ResolverInterface $themeResolver, Layout\ReaderPool $readerPool, Layout\GeneratorPool $generatorPool, FrontendInterface $cache, Layout\Reader\ContextFactory $readerContextFactory, Layout\Generator\ContextFactory $generatorContextFactory, AppState $appState, Logger $logger, $cacheable=true, SerializerInterface $serializer=null)
setGeneratorPool(Layout\GeneratorPool $generatorPool)
renderNonCachedElement($name)
addToOutputRootContainers()
setIsPrivate($isPrivate=true)
const CONTAINER_OPT_LABEL
if(!isset($_GET['name'])) $name