Esempio n. 1
0
 /**
  * Add element to parent group
  *
  * @param string $blockName
  * @param string $parentGroupName
  * @return bool
  */
 public function addToParentGroup($blockName, $parentGroupName)
 {
     $this->build();
     return $this->structure->addToParentGroup($blockName, $parentGroupName);
 }
Esempio n. 2
0
 /**
  * Create component object
  *
  * @param Structure $structure
  * @param string $elementName
  * @param string $data
  * @param LayoutInterface $layout
  * @return ContainerInterface
  */
 protected function generateComponent(Structure $structure, $elementName, $data, LayoutInterface $layout)
 {
     $attributes = $data['attributes'];
     if (!empty($attributes['group'])) {
         $structure->addToParentGroup($elementName, $attributes['group']);
     }
     $context = $this->contextFactory->create(['namespace' => $elementName, 'pageLayout' => $layout]);
     $component = $this->uiComponentFactory->create($elementName, null, ['context' => $context]);
     $this->prepareComponent($component);
     /** @var ContainerInterface $blockContainer */
     $blockContainer = $this->blockFactory->createBlock(static::CONTAINER, ['component' => $component]);
     return $blockContainer;
 }
Esempio n. 3
0
 /**
  * Create block and set related data
  *
  * @param \Magento\Framework\View\Layout\ScheduledStructure $scheduledStructure
  * @param \Magento\Framework\View\Layout\Data\Structure $structure
  * @param string $elementName
  * @return \Magento\Framework\View\Element\AbstractBlock
  */
 protected function generateBlock(Layout\ScheduledStructure $scheduledStructure, Layout\Data\Structure $structure, $elementName)
 {
     list(, $data) = $scheduledStructure->getElement($elementName);
     $attributes = $data['attributes'];
     if (!empty($attributes['group'])) {
         $structure->addToParentGroup($elementName, $attributes['group']);
     }
     if (!empty($attributes['display'])) {
         $structure->setAttribute($elementName, 'display', $attributes['display']);
     }
     // create block
     $className = $attributes['class'];
     $block = $this->createBlock($className, $elementName, ['data' => $this->evaluateArguments($data['arguments'])]);
     if (!empty($attributes['template'])) {
         $block->setTemplate($attributes['template']);
     }
     if (!empty($attributes['ttl'])) {
         $ttl = (int) $attributes['ttl'];
         $block->setTtl($ttl);
     }
     return $block;
 }
Esempio n. 4
0
 /**
  * Create component object
  *
  * @param \Magento\Framework\View\Layout\Data\Structure $structure
  * @param string $elementName
  * @param string $data
  * @return \Magento\Framework\View\Element\UiComponentInterface
  */
 protected function generateComponent(Layout\Data\Structure $structure, $elementName, $data)
 {
     $attributes = $data['attributes'];
     if (!empty($attributes['group'])) {
         $structure->addToParentGroup($elementName, $attributes['group']);
     }
     $arguments = empty($data['arguments']) ? [] : $this->evaluateArguments($data['arguments']);
     $componentName = isset($attributes['component']) ? $attributes['component'] : '';
     $uiComponent = $this->uiComponentFactory->createUiComponent($componentName, $elementName, $arguments);
     return $uiComponent;
 }