Exemple #1
0
 /**
  * Prepare component configuration
  *
  * @return void
  */
 public function prepare()
 {
     $config = (array) $this->getData('config');
     $config['content'] = $this->block->toHtml();
     $this->setData('config', $config);
     parent::prepare();
 }
 /**
  * @inheritDoc
  */
 public function prepare()
 {
     if (!empty($this->actions)) {
         $this->setData('config', array_replace_recursive(['actions' => $this->actions], $this->getConfiguration()));
     }
     parent::prepare();
 }
Exemple #3
0
 /**
  * Register component
  *
  * @return void
  */
 public function prepare()
 {
     parent::prepare();
     $jsConfig = $this->getConfiguration($this);
     unset($jsConfig['extends']);
     $this->getContext()->addComponentDefinition($this->getContext()->getNamespace(), $jsConfig);
     $this->getContext()->addButtons($this->getData('buttons'), $this);
 }
 /**
  * @param array $jsConfig
  * @param array $expectedResult
  * @return void
  * @dataProvider getJsConfigDataProvider
  */
 public function testGetJsConfig(array $jsConfig, array $expectedResult)
 {
     $namespace = 'my_namespace';
     /** @var \Magento\Framework\View\Element\UiComponentInterface|MockObject $uiComponentMock */
     $uiComponentMock = $this->getMockBuilder('Magento\\Framework\\View\\Element\\UiComponentInterface')->setMethods(['getData'])->getMockForAbstractClass();
     $uiComponentMock->expects($this->once())->method('getData')->with('js_config')->willReturnOnConsecutiveCalls($jsConfig);
     $uiComponentMock->expects($this->any())->method('getContext')->willReturn($this->contextMock);
     $this->contextMock->expects($this->any())->method('getNamespace')->willReturn($namespace);
     $this->assertEquals($expectedResult, $this->abstractComponent->getJsConfig($uiComponentMock));
 }
Exemple #5
0
 /**
  * Prepare component configuration
  *
  * @return void
  */
 public function prepare()
 {
     parent::prepare();
     $config = $this->getData('config');
     if (isset($config['update_url'])) {
         $config['update_url'] = $this->getContext()->getUrl($config['update_url']);
         $this->setData('config', $config);
     }
     $jsConfig = $this->getConfiguration($this);
     unset($jsConfig['extends']);
     $this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
 }
 /**
  * Prepare component configuration
  *
  * @return void
  */
 public function prepare()
 {
     foreach ($this->getChildComponents() as $column) {
         if ($column instanceof Column) {
             $meta = $this->getContext()->getDataProvider()->getFieldMetaInfo($this->getName(), $column->getName());
             if ($meta) {
                 $config = $column->getData('config');
                 $config = array_replace_recursive($config, $meta);
                 $column->setData('config', $config);
             }
         }
     }
     parent::prepare();
 }
Exemple #7
0
 /**
  * Prepare component configuration
  *
  * @return void
  */
 public function prepare()
 {
     parent::prepare();
     $dataType = $this->getData('config/dataType');
     $wrappedComponentConfig = [];
     if ($dataType) {
         $this->wrappedComponent = $this->uiComponentFactory->create($this->getName(), $dataType, array_merge(['context' => $this->getContext()], (array) $this->getData()));
         $this->wrappedComponent->prepare();
         $wrappedComponentConfig = $this->getConfiguration($this->wrappedComponent);
     }
     $this->applySorting();
     $jsConfig = array_replace_recursive($wrappedComponentConfig, $this->getConfiguration($this));
     $this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
 }
 /**
  * @return void
  */
 public function prepare()
 {
     $config = $this->getData('config');
     if (isset($config['options'])) {
         $options = [];
         foreach ($config['options'] as $option) {
             $option['url'] = $this->urlBuilder->getUrl($option['url']);
             $options[] = $option;
         }
         $config['options'] = $options;
         $this->setData('config', $config);
     }
     parent::prepare();
 }
Exemple #9
0
 /**
  * Prepare component configuration
  *
  * @return void
  */
 public function prepare()
 {
     $dataType = $this->getData('config/dataType');
     if ($dataType) {
         $this->wrappedComponent = $this->uiComponentFactory->create($this->getName(), $dataType, array_merge(['context' => $this->getContext()], (array) $this->getData()));
         $this->wrappedComponent->prepare();
         $wrappedComponentConfig = $this->getJsConfig($this->wrappedComponent);
         // Merge JS configuration with wrapped component configuration
         $jsConfig = array_replace_recursive($wrappedComponentConfig, $this->getJsConfig($this));
         $this->setData('js_config', $jsConfig);
         $this->setData('config', array_replace_recursive((array) $this->wrappedComponent->getData('config'), (array) $this->getData('config')));
     }
     $this->applySorting();
     parent::prepare();
 }
Exemple #10
0
 /**
  * Register component
  *
  * @return void
  */
 public function prepare()
 {
     $config = $this->getData('config');
     if (isset($config['actions'])) {
         $config['actions'] = array_values($config['actions']);
         array_walk_recursive($config['actions'], function (&$item, $key, $context) {
             /** @var ContextInterface $context */
             if ($key === 'url') {
                 $item = $context->getUrl($item);
             }
         }, $this->getContext());
         $this->setData('config', $config);
     }
     parent::prepare();
 }
Exemple #11
0
 /**
  * Prepare component configuration
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function prepare()
 {
     parent::prepare();
     $formElement = $this->getData('config/formElement');
     if (null === $formElement) {
         throw new LocalizedException(__('The configuration parameter "formElement" is a required for "' . $this->getName() . '" field.'));
     }
     // Create of wrapped component
     $this->wrappedComponent = $this->uiComponentFactory->create($this->getName(), $formElement, array_merge(['context' => $this->getContext()], (array) $this->getData()));
     $this->wrappedComponent->prepare();
     // To prepare the component configuration
     $wrappedComponentConfig = $this->getConfiguration($this->wrappedComponent);
     $jsConfig = array_replace_recursive($wrappedComponentConfig, $this->getConfiguration($this, $this->wrappedComponent->getComponentName()));
     $this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
 }
Exemple #12
0
 /**
  * Prepare component configuration
  *
  * @return void
  */
 public function prepare()
 {
     foreach ($this->getChildComponents() as $name => $child) {
         if ($child instanceof Container) {
             $this->fieldsInContainers += $child->getChildComponents();
         }
     }
     $fieldsMeta = $this->getContext()->getDataProvider()->getFieldsMetaInfo($this->getName());
     foreach ($fieldsMeta as $name => $fieldData) {
         if (empty($fieldData)) {
             continue;
         }
         $fieldComponent = $this->getComponent($name);
         $this->prepareField($fieldData, $name, $fieldComponent);
     }
     parent::prepare();
 }
Exemple #13
0
 /**
  * Prepare component configuration
  *
  * @return void
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function prepare()
 {
     $formElement = $this->getData('config/formElement');
     if (null === $formElement) {
         throw new LocalizedException(__('The configuration parameter "formElement" is a required for "' . $this->getName() . '" field.'));
     }
     // Create of wrapped component
     $this->wrappedComponent = $this->uiComponentFactory->create($this->getName(), $formElement, array_merge(['context' => $this->getContext()], (array) $this->getData()));
     $this->wrappedComponent->prepare();
     // Merge JS configuration with wrapped component configuration
     $wrappedComponentConfig = $this->getJsConfig($this->wrappedComponent);
     $jsConfig = array_replace_recursive($wrappedComponentConfig, $this->getJsConfig($this));
     $jsConfig['extends'] = $this->wrappedComponent->getComponentName();
     $this->setData('js_config', $jsConfig);
     $this->setData('config', array_replace_recursive((array) $this->wrappedComponent->getData('config'), (array) $this->getData('config')));
     parent::prepare();
 }
Exemple #14
0
 /**
  * Register component
  *
  * @return void
  */
 public function prepare()
 {
     $namespace = $this->getContext()->getRequestParam('namespace', $this->getContext()->getNamespace());
     $config = [];
     if (!empty($namespace)) {
         $bookmarks = $this->bookmarkManagement->loadByNamespace($namespace);
         /** @var \Magento\Ui\Api\Data\BookmarkInterface $bookmark */
         foreach ($bookmarks->getItems() as $bookmark) {
             if ($bookmark->isCurrent()) {
                 $config['activeIndex'] = $bookmark->getIdentifier();
             }
             $config = array_merge_recursive($config, $bookmark->getConfig());
         }
     }
     $this->setData('config', array_replace_recursive($config, $this->getConfiguration($this)));
     parent::prepare();
     $jsConfig = $this->getConfiguration($this);
     $this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
 }
Exemple #15
0
 /**
  * @param ContextInterface $context
  * @param FilterBuilder $filterBuilder
  * @param UiComponentInterface[] $components
  * @param array $data
  */
 public function __construct(ContextInterface $context, FilterBuilder $filterBuilder, array $components = [], array $data = [])
 {
     $this->filterBuilder = $filterBuilder;
     parent::__construct($context, $components, $data);
 }
 /**
  * @inheritDoc
  */
 public function getChildComponents()
 {
     $result = parent::getChildComponents();
     foreach (array_keys($this->columnFilters) as $componentName) {
         if ($this->getComponent($componentName)) {
             unset($result[$componentName]);
         }
     }
     return $result;
 }
Exemple #17
0
 /**
  * Constructor
  *
  * @param ContextInterface $context
  * @param UiComponentFactory $uiComponentFactory
  * @param array $components
  * @param array $data
  */
 public function __construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, array $components = [], array $data = [])
 {
     $this->uiComponentFactory = $uiComponentFactory;
     parent::__construct($context, $components, $data);
 }
 /**
  * Constructor
  *
  * @param ContextInterface $context
  * @param BlockInterface $block
  * @param array $components
  * @param array $data
  */
 public function __construct(ContextInterface $context, BlockInterface $block, array $components = [], array $data = [])
 {
     $this->block = $block;
     parent::__construct($context, $components, $data);
 }
Exemple #19
0
 /**
  * Constructor
  *
  * @param ContextInterface $context
  * @param UiComponentFactory $uiComponentFactory
  * @param array $components
  * @param array $data
  */
 public function __construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, array $components = [], array $data = [])
 {
     $this->uiComponentFactory = $uiComponentFactory;
     parent::__construct($context, $components, $data);
     $this->filterData = $this->getContext()->getRequestParam(static::FILTER_VAR);
 }
Exemple #20
0
 /**
  * Constructor
  *
  * @param ContextInterface $context
  * @param UiComponentFactory $uiComponentFactory
  * @param array $components
  * @param array $data
  */
 public function __construct(ContextInterface $context, UiComponentFactory $uiComponentFactory, array $components = [], array $data = [])
 {
     $this->uiComponentFactory = $uiComponentFactory;
     parent::__construct($context, $components, $data);
     $this->filterData = $this->getContext()->getFiltersParams();
 }
Exemple #21
0
 /**
  * Register component and build layout structure
  *
  * @inheritdoc
  */
 public function prepare()
 {
     $this->layoutTypeObject = $this->layoutPool->create($this->type);
     $this->structure = $this->layoutTypeObject->build($this);
     parent::prepare();
 }
 /**
  * Constructor
  *
  * @param ContextInterface $context
  * @param DataProviderInterface $dataProvider
  * @param array $components
  * @param array $data
  */
 public function __construct(ContextInterface $context, DataProviderInterface $dataProvider, array $components = [], array $data = [])
 {
     $this->dataProvider = $dataProvider;
     $context->setDataProvider($dataProvider);
     parent::__construct($context, $components, $data);
 }
Exemple #23
0
 /**
  * Prepare component configuration
  *
  * @return void
  */
 public function prepare()
 {
     parent::prepare();
     $jsConfig = $this->getConfiguration($this);
     $this->getContext()->addComponentDefinition($this->getComponentName(), $jsConfig);
 }
 /**
  * @return void
  */
 public function prepare()
 {
     $config = $this->getData('config');
     if (isset($config['options'])) {
         $options = [];
         foreach ($config['options'] as $option) {
             $option['url'] = $this->urlBuilder->getUrl($option['url']);
             $options[] = $option;
         }
         $config['options'] = $options;
     }
     $store = $this->storeManager->getStore();
     $config['validationEnabled'] = $this->config->isAddressValidationEnabled($store);
     $hasChoice = $this->config->allowUserToChooseAddress($store);
     if ($hasChoice) {
         $instructions = $this->config->getAddressValidationInstructionsWithChoice($store);
     } else {
         $instructions = $this->config->getAddressValidationInstructionsWithOutChoice($store);
     }
     $config['instructions'] = $instructions;
     $config['errorInstructions'] = $this->config->getAddressValidationErrorInstructions($store);
     $config['countriesEnabled'] = $this->config->getAddressValidationCountriesEnabled($store);
     $config['baseUrl'] = $this->urlBuilder->getUrl(self::VALIDATE_ADDRESS_PATH);
     $this->setData('config', $config);
     parent::prepare();
 }
Exemple #25
0
 /**
  * Constructor
  *
  * @param ContextInterface $context
  * @param LayoutPool $layoutPool
  * @param string $type
  * @param array $components
  * @param array $data
  */
 public function __construct(ContextInterface $context, LayoutPool $layoutPool, $type, array $components = [], array $data = [])
 {
     $this->layoutPool = $layoutPool;
     $this->type = $type;
     parent::__construct($context, $components, $data);
 }
 /**
  * {@inheritdoc}
  */
 public function prepare()
 {
     $this->filterModifier->applyFilterModifier($this->getContext()->getDataProvider(), $this->getName());
     parent::prepare();
 }