예제 #1
0
파일: Context.php 프로젝트: opexsw/magento2
 /**
  * Add button in the actions toolbar
  *
  * @param array $buttons
  * @param UiComponentInterface $component
  * @return void
  */
 public function addButtons(array $buttons, UiComponentInterface $component)
 {
     if (!empty($buttons)) {
         foreach ($buttons as $buttonId => $buttonData) {
             if (is_array($buttonData)) {
                 $buttons[$buttonId] = $buttonData;
                 continue;
             }
             /** @var ButtonProviderInterface $button */
             $button = $this->buttonProviderFactory->create($buttonData);
             $buttonData = $button->getButtonData();
             if (!$buttonData) {
                 unset($buttons[$buttonId]);
                 continue;
             }
             $buttons[$buttonId] = $buttonData;
         }
         uasort($buttons, [$this, 'sortButtons']);
         foreach ($buttons as $buttonId => $buttonData) {
             if (isset($buttonData['url'])) {
                 $buttonData['url'] = $this->getUrl($buttonData['url']);
             }
             $this->actionPool->add($buttonId, $buttonData, $component);
         }
     }
 }
예제 #2
0
 /**
  * {@inheritdoc}
  * @SuppressWarnings(PHPMD.UnusedLocalVariable)
  */
 public function addHtmlBlocks(array $htmlBlocks, UiComponentInterface $component)
 {
     if (!empty($htmlBlocks)) {
         foreach ($htmlBlocks as $htmlBlock => $blockData) {
             $this->actionPool->addHtmlBlock($blockData['type'], $blockData['name'], $blockData['arguments']);
         }
     }
 }