Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ConfigurationPool.php
Go to the documentation of this file.
1 <?php
7 
13 {
17  protected $_objectManager;
18 
22  private $_instances = [];
23 
27  private $instancesByType = [];
28 
33  public function __construct(\Magento\Framework\ObjectManagerInterface $objectManager, array $instancesByType)
34  {
35  $this->_objectManager = $objectManager;
36  $this->instancesByType = $instancesByType;
37  }
38 
44  public function get($className)
45  {
46  if (!isset($this->_instances[$className])) {
48  $helperInstance = $this->_objectManager->get($className);
49  if (false ===
50  $helperInstance instanceof \Magento\Catalog\Helper\Product\Configuration\ConfigurationInterface
51  ) {
52  throw new \LogicException(
53  "{$className} doesn't implement " .
54  \Magento\Catalog\Helper\Product\Configuration\ConfigurationInterface::class
55  );
56  }
57  $this->_instances[$className] = $helperInstance;
58  }
59  return $this->_instances[$className];
60  }
61 
66  public function getByProductType($productType)
67  {
68  if (!isset($this->instancesByType[$productType])) {
69  return $this->instancesByType['default'];
70  }
71  return $this->instancesByType[$productType];
72  }
73 }
$objectManager
Definition: bootstrap.php:17
__construct(\Magento\Framework\ObjectManagerInterface $objectManager, array $instancesByType)
if($currentSelectedMethod==$_code) $className
Definition: form.phtml:31