Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UiComponent.php
Go to the documentation of this file.
1 <?php
7 
12 
18 class UiComponent extends Template implements ContainerInterface
19 {
25  protected $component;
26 
31 
40  public function __construct(
41  TemplateContext $context,
43  BlockFactory $blockWrapperFactory,
44  array $data = []
45  ) {
46  $this->component = $component;
47  $this->blockWrapperFactory = $blockWrapperFactory;
48  $this->setNameInLayout($this->component->getName());
49  parent::__construct($context, $data);
50  }
51 
57  protected function _toHtml()
58  {
59  foreach ($this->getChildNames() as $childName) {
60  $childBlock = $this->getLayout()->getBlock($childName);
61  if ($childBlock) {
62  $wrapper = $this->blockWrapperFactory->create([
63  'block' => $childBlock,
64  'data' => [
65  'name' => 'block_' . $childName
66  ]
67  ]);
68  $this->component->addComponent('block_' . $childName, $wrapper);
69  }
70  }
71 
72  $result = $this->component->render();
73  return (string)$result;
74  }
75 }
__construct(TemplateContext $context, UiComponentInterface $component, BlockFactory $blockWrapperFactory, array $data=[])
Definition: UiComponent.php:40