Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
Pool.php
Go to the documentation of this file.
1 <?php
7 
10 
14 class Pool
15 {
16  const DEFAULT_CLASS = \Magento\Framework\View\Layout\Generic::class;
17 
23  protected $types;
24 
28  protected $objectManager;
29 
36  public function __construct(
38  array $types = []
39  ) {
40  $this->objectManager = $objectManager;
41  $this->types = $types;
42  }
43 
51  public function create($layoutType, array $arguments = [])
52  {
53  if (!isset($this->types[$layoutType])) {
54  throw new \InvalidArgumentException(sprintf('Unknown layout type "%s"', $layoutType));
55  }
56  $defArgs = $this->types[$layoutType];
57  $class = isset($defArgs['class']) ? $defArgs['class'] : self::DEFAULT_CLASS;
58  unset($defArgs['class']);
59  if ($defArgs) {
60  $arguments = array_merge($defArgs, $arguments);
61  }
62  return $this->objectManager->create($class, $arguments);
63  }
64 }
__construct(ObjectManagerInterface $objectManager, array $types=[])
Definition: Pool.php:36
$_option $_optionId $class
Definition: date.phtml:13
create($layoutType, array $arguments=[])
Definition: Pool.php:51
$arguments