Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
BuilderComposite.php
Go to the documentation of this file.
1 <?php
7 
10 
17 {
21  private $builders;
22 
27  public function __construct(
28  TMapFactory $tmapFactory,
29  array $builders = []
30  ) {
31  $this->builders = $tmapFactory->create(
32  [
33  'array' => $builders,
34  'type' => BuilderInterface::class
35  ]
36  );
37  }
38 
45  public function build(array $buildSubject)
46  {
47  $result = [];
48  foreach ($this->builders as $builder) {
49  // @TODO implement exceptions catching
50  $result = $this->merge($result, $builder->build($buildSubject));
51  }
52 
53  return $result;
54  }
55 
63  protected function merge(array $result, array $builder)
64  {
65  return array_replace_recursive($result, $builder);
66  }
67 }
__construct(TMapFactory $tmapFactory, array $builders=[])