示例#1
0
 /**
  * Prepare component data
  *
  * @return void
  */
 public function prepare()
 {
     $this->registerComponents();
     $buttons = $this->getData('buttons');
     if ($buttons) {
         foreach ($buttons as $buttonId => $buttonClass) {
             /** @var ButtonProviderInterface $button */
             $button = $this->buttonProviderFactory->create($buttonClass);
             $buttonData = $button->getButtonData();
             if (!$buttonData) {
                 unset($buttons[$buttonId]);
                 continue;
             }
             $buttons[$buttonId] = $buttonData;
         }
         uasort($buttons, [$this, 'sortButtons']);
         foreach ($buttons as $buttonId => $buttonData) {
             $this->actionPool->add($buttonId, $buttonData, $this);
         }
     }
     $layoutSettings = (array) $this->getData('layout');
     $data = ['name' => $this->getData('name'), 'label' => $this->getData('label'), 'data_sources' => $this->getData('data_sources'), 'child_blocks' => $this->getLayout()->getChildBlocks($this->getNameInLayout()), 'configuration' => isset($layoutSettings['configuration']) ? $layoutSettings['configuration'] : []];
     $layoutType = isset($layoutSettings['type']) ? $layoutSettings['type'] : \Magento\Ui\Component\Layout\Tabs::NAME;
     $layout = $this->factory->create($layoutType, $data);
     $layout->prepare();
     $this->elements[] = $layout;
 }
 /**
  * @inheritdoc
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function prepare()
 {
     $this->ns = $this->getData('name');
     $this->initSections();
     $this->initAreas();
     $this->initGroups();
     $this->initElements();
     foreach ($this->getDataSources() as $name => $dataSourceConfig) {
         $this->processDataSource($dataSourceConfig);
     }
     $this->processChildBLocks();
     $this->renderContext->getStorage()->addLayoutStructure($this->getDataScope(), ['children' => $this->structure]);
     $navBlock = $this->factory->create(\Magento\Ui\Component\Layout\Tabs\Nav::NAME, ['data_scope' => $this->ns]);
     if ($this->getData('configuration/tabs_container_name')) {
         $this->getRenderContext()->getPageLayout()->addBlock($navBlock, 'tabs_nav', $this->getData('configuration/tabs_container_name'));
     } else {
         $this->getRenderContext()->getPageLayout()->addBlock($navBlock, 'tabs_nav', 'content');
     }
 }