Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Builder.php
Go to the documentation of this file.
1 <?php
7 
11 
16 class Builder
17 {
21  private $results = [];
22 
26  private $urlBuilder;
27 
31  private $structureElementTypes;
32 
37  public function __construct(UrlInterface $urlBuilder, array $structureElementTypes)
38  {
39  $this->urlBuilder = $urlBuilder;
40  $this->structureElementTypes = $structureElementTypes;
41  }
42 
46  public function getAll()
47  {
48  return $this->results;
49  }
50 
56  public function add(StructureElementInterface $structureElement, $elementPathLabel)
57  {
58  $urlParams = [];
59  $elementData = $structureElement->getData();
60 
61  if (!in_array($elementData['_elementType'], array_keys($this->structureElementTypes))) {
62  return;
63  }
64 
65  if (isset($this->structureElementTypes[$elementData['_elementType']])) {
66  $urlParamsBuilder = $this->structureElementTypes[$elementData['_elementType']];
67  $urlParams = $urlParamsBuilder->build($structureElement);
68  }
69 
70  $this->results[] = [
71  'id' => $structureElement->getPath(),
72  'type' => null,
73  'name' => (string)$structureElement->getLabel(),
74  'description' => $elementPathLabel,
75  'url' => $this->urlBuilder->getUrl('*/system_config/edit', $urlParams),
76  ];
77  }
78 }
add(StructureElementInterface $structureElement, $elementPathLabel)
Definition: Builder.php:56
__construct(UrlInterface $urlBuilder, array $structureElementTypes)
Definition: Builder.php:37