Example #1
0
 /**
  * Destroy previous element with same name and all its children, if new element overrides it
  *
  * This is a workaround to handle situation, when an element emerges with name of element that already exists.
  * In this case we destroy entire structure of the former element and replace with the new one.
  *
  * @param Layout\ScheduledStructure $scheduledStructure
  * @param string $name
  * @param string $path
  * @return void
  */
 protected function _overrideElementWorkaround(Layout\ScheduledStructure $scheduledStructure, $name, $path)
 {
     if ($scheduledStructure->hasStructureElement($name)) {
         $scheduledStructure->setStructureElementData($name, []);
         foreach ($scheduledStructure->getPaths() as $potentialChild => $childPath) {
             if (0 === strpos($childPath, "{$path}/")) {
                 $scheduledStructure->unsetPathElement($potentialChild);
                 $scheduledStructure->unsetStructureElement($potentialChild);
             }
         }
     }
 }
Example #2
0
 /**
  * Schedule reference data
  *
  * @param Layout\ScheduledStructure $scheduledStructure
  * @param Layout\Element $currentElement
  * @return void
  */
 protected function scheduleReference(Layout\ScheduledStructure $scheduledStructure, Layout\Element $currentElement)
 {
     $elementName = $currentElement->getAttribute('name');
     $elementRemove = filter_var($currentElement->getAttribute('remove'), FILTER_VALIDATE_BOOLEAN);
     if ($elementRemove) {
         $scheduledStructure->setElementToRemoveList($elementName);
     } else {
         $data = $scheduledStructure->getStructureElementData($elementName, []);
         $data['attributes'] = $this->mergeBlockAttributes($data, $currentElement);
         $this->updateScheduledData($currentElement, $data);
         $this->evaluateArguments($currentElement, $data);
         $scheduledStructure->setStructureElementData($elementName, $data);
     }
 }
Example #3
0
 /**
  * Schedule reference data
  *
  * @param Layout\ScheduledStructure $scheduledStructure
  * @param Layout\Element $currentElement
  * @return void
  */
 protected function scheduleReference(Layout\ScheduledStructure $scheduledStructure, Layout\Element $currentElement)
 {
     $elementName = $currentElement->getAttribute('name');
     $data = $scheduledStructure->getStructureElementData($elementName, []);
     $this->updateScheduledData($currentElement, $data);
     $this->evaluateArguments($currentElement, $data);
     $scheduledStructure->setStructureElementData($elementName, $data);
 }
 /**
  * Merge Container attributes
  *
  * @param \Magento\Framework\View\Layout\ScheduledStructure $scheduledStructure
  * @param \Magento\Framework\View\Layout\Element $currentElement
  * @return void
  */
 protected function mergeContainerAttributes(Layout\ScheduledStructure $scheduledStructure, Layout\Element $currentElement)
 {
     $containerName = $currentElement->getAttribute('name');
     $elementData = $scheduledStructure->getStructureElementData($containerName);
     if (isset($elementData['attributes'])) {
         $keys = array_keys($elementData['attributes']);
         foreach ($keys as $key) {
             if (isset($currentElement[$key])) {
                 $elementData['attributes'][$key] = (string) $currentElement[$key];
             }
         }
     } else {
         $elementData['attributes'] = [self::CONTAINER_OPT_HTML_TAG => (string) $currentElement[self::CONTAINER_OPT_HTML_TAG], self::CONTAINER_OPT_HTML_ID => (string) $currentElement[self::CONTAINER_OPT_HTML_ID], self::CONTAINER_OPT_HTML_CLASS => (string) $currentElement[self::CONTAINER_OPT_HTML_CLASS], self::CONTAINER_OPT_LABEL => (string) $currentElement[self::CONTAINER_OPT_LABEL], self::CONTAINER_OPT_DISPLAY => (string) $currentElement[self::CONTAINER_OPT_DISPLAY]];
     }
     $scheduledStructure->setStructureElementData($containerName, $elementData);
 }