/** * 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); }
/** * 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(); }
/** * To prepare the structure of child components * * @param UiComponentInterface $component * @param string $parentName * @return array */ protected function prepareChildComponents(UiComponentInterface $component, $parentName) { $name = $component->getName(); $childComponents = $component->getChildComponents(); $childrenStructure = []; foreach ($childComponents as $childName => $child) { $isVisible = $child->getData('config/visible'); if ($isVisible !== null && $isVisible == 0) { continue; } /** * @var UiComponentInterface $childComponent * @var array $childStructure */ list($childComponent, $childStructure) = $this->prepareChildComponents($child, $component->getName()); $childrenStructure = array_merge($childrenStructure, $childStructure); $component->addComponent($childName, $childComponent); } $structure = [$name => ['type' => $component->getComponentName(), 'name' => $component->getName(), 'children' => $childrenStructure]]; list($config, $dataScope) = $this->prepareConfig((array) $component->getConfiguration(), $name, $parentName); if ($dataScope !== false) { $structure[$name]['dataScope'] = $dataScope; } $structure[$name]['config'] = $config; return [$component, $structure]; }