Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
CompositeFieldProvider.php
Go to the documentation of this file.
1 <?php
6 declare(strict_types=1);
7 
9 
14 {
18  private $providers;
19 
23  public function __construct(array $providers)
24  {
25  foreach ($providers as $provider) {
26  if (!$provider instanceof FieldProviderInterface) {
27  throw new \InvalidArgumentException(
28  sprintf('Instance of the field provider is expected, got %s instead.', get_class($provider))
29  );
30  }
31  }
32  $this->providers = $providers;
33  }
34 
41  public function getFields(array $context = []): array
42  {
43  $allAttributes = [];
44 
45  foreach ($this->providers as $provider) {
46  $allAttributes = array_merge($allAttributes, $provider->getFields($context));
47  }
48 
49  return $allAttributes;
50  }
51 }