Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
GeneratorResolver.php
Go to the documentation of this file.
1 <?php
8 
16 {
20  private $generators;
21 
25  private $defaultGenerator;
26 
31  public function __construct(GeneratorInterface $defaultGenerator, array $generators)
32  {
33  $this->defaultGenerator = $defaultGenerator;
34  $this->generators = $generators;
35  }
36 
43  public function getGeneratorForType($type)
44  {
45  $generator = isset($this->generators[$type]) ? $this->generators[$type] : $this->defaultGenerator;
46  if (!($generator instanceof GeneratorInterface)) {
47  throw new \InvalidArgumentException(
48  'Generator must implement ' . GeneratorInterface::class
49  );
50  }
51  return $generator;
52  }
53 }
__construct(GeneratorInterface $defaultGenerator, array $generators)
$type
Definition: item.phtml:13