Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UiComponentGenerator.php
Go to the documentation of this file.
1 <?php
6 namespace Magento\Ui\Model;
7 
11 
20 {
24  private $contextFactory;
25 
29  private $uiComponentFactory;
30 
37  public function __construct(
38  ContextFactory $contextFactory,
39  UiComponentFactory $uiComponentFactory
40  ) {
41  $this->contextFactory = $contextFactory;
42  $this->uiComponentFactory = $uiComponentFactory;
43  }
44 
52  public function generateUiComponent($name, \Magento\Framework\View\LayoutInterface $layout)
53  {
54  $context = $this->contextFactory->create([
55  'namespace' => $name,
56  'pageLayout' => $layout,
57  ]);
58 
59  $component = $this->uiComponentFactory->create(
60  $name,
61  null,
62  [
63  'context' => $context
64  ]
65  );
66  return $this->prepareComponent($component);
67  }
68 
75  private function prepareComponent(UiComponentInterface $component)
76  {
77  $childComponents = $component->getChildComponents();
78  if (!empty($childComponents)) {
79  foreach ($childComponents as $child) {
80  $this->prepareComponent($child);
81  }
82  }
83  $component->prepare();
84 
85  return $component;
86  }
87 }
generateUiComponent($name, \Magento\Framework\View\LayoutInterface $layout)
__construct(ContextFactory $contextFactory, UiComponentFactory $uiComponentFactory)
if(!isset($_GET['name'])) $name
Definition: log.php:14