Example #1
0
 /**
  * Populate queue for generating structural elements
  *
  * @param Layout\ScheduledStructure $scheduledStructure
  * @param \Magento\Framework\View\Layout\Element $currentNode
  * @param \Magento\Framework\View\Layout\Element $parentNode
  * @return string
  * @see scheduleElement() where the scheduledStructure is used
  */
 public function scheduleStructure(Layout\ScheduledStructure $scheduledStructure, Layout\Element $currentNode, Layout\Element $parentNode)
 {
     // if it hasn't a name it must be generated
     if (!(string) $currentNode->getAttribute('name')) {
         $name = $this->_generateAnonymousName($parentNode->getElementName() . '_schedule_block');
         $currentNode->setAttribute('name', $name);
     }
     $path = $name = (string) $currentNode->getAttribute('name');
     // Prepare scheduled element with default parameters [type, alias, parentName, siblingName, isAfter]
     $row = [self::SCHEDULED_STRUCTURE_INDEX_TYPE => $currentNode->getName(), self::SCHEDULED_STRUCTURE_INDEX_ALIAS => '', self::SCHEDULED_STRUCTURE_INDEX_PARENT_NAME => '', self::SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME => null, self::SCHEDULED_STRUCTURE_INDEX_IS_AFTER => true];
     $parentName = $parentNode->getElementName();
     //if this element has a parent element, there must be reset [alias, parentName, siblingName, isAfter]
     if ($parentName) {
         $row[self::SCHEDULED_STRUCTURE_INDEX_ALIAS] = (string) $currentNode->getAttribute('as');
         $row[self::SCHEDULED_STRUCTURE_INDEX_PARENT_NAME] = $parentName;
         list($row[self::SCHEDULED_STRUCTURE_INDEX_SIBLING_NAME], $row[self::SCHEDULED_STRUCTURE_INDEX_IS_AFTER]) = $this->_beforeAfterToSibling($currentNode);
         // materialized path for referencing nodes in the plain array of _scheduledStructure
         if ($scheduledStructure->hasPath($parentName)) {
             $path = $scheduledStructure->getPath($parentName) . '/' . $path;
         }
     }
     $this->_overrideElementWorkaround($scheduledStructure, $name, $path);
     $scheduledStructure->setPathElement($name, $path);
     $scheduledStructure->setStructureElement($name, $row);
     return $name;
 }
Example #2
0
 /**
  * Run action defined in layout update
  *
  * @param \Magento\Framework\View\Layout\Element $node
  * @param \Magento\Framework\View\Layout\Element $parent
  * @return void
  */
 protected function _generateAction($node, $parent)
 {
     $configPath = $node->getAttribute('ifconfig');
     if ($configPath && !$this->_scopeConfig->isSetFlag($configPath, $this->scopeType, $this->scopeResolver->getScope())) {
         return;
     }
     $method = $node->getAttribute('method');
     $parentName = $node->getAttribute('block');
     if (empty($parentName)) {
         $parentName = $parent->getElementName();
     }
     $profilerKey = 'BLOCK_ACTION:' . $parentName . '>' . $method;
     \Magento\Framework\Profiler::start($profilerKey);
     $block = $this->getBlock($parentName);
     if (!empty($block)) {
         $args = $this->_parseArguments($node);
         $args = $this->_evaluateArguments($args);
         call_user_func_array(array($block, $method), $args);
     }
     \Magento\Framework\Profiler::stop($profilerKey);
 }