![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/framework/ObjectManager/ |
<?php /** * Magento object manager. Responsible for instantiating objects taking into account: * - constructor arguments (using configured, and provided parameters) * - class instances life style (singleton, transient) * - interface preferences * * Intentionally contains multiple concerns for best performance * * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\ObjectManager; class ObjectManager implements \Magento\Framework\ObjectManagerInterface { /** * @var \Magento\Framework\ObjectManager\FactoryInterface */ protected $_factory; /** * List of shared instances * * @var array */ protected $_sharedInstances = []; /** * @var ConfigInterface */ protected $_config; /** * @param FactoryInterface $factory * @param ConfigInterface $config * @param array &$sharedInstances */ public function __construct(FactoryInterface $factory, ConfigInterface $config, &$sharedInstances = []) { $this->_config = $config; $this->_factory = $factory; $this->_sharedInstances = &$sharedInstances; $this->_sharedInstances[\Magento\Framework\ObjectManagerInterface::class] = $this; } /** * Create new object instance * * @param string $type * @param array $arguments * @return mixed */ public function create($type, array $arguments = []) { return $this->_factory->create($this->_config->getPreference($type), $arguments); } /** * Retrieve cached object instance * * @param string $type * @return mixed */ public function get($type) { $type = ltrim($type, '\\'); $type = $this->_config->getPreference($type); if (!isset($this->_sharedInstances[$type])) { $this->_sharedInstances[$type] = $this->_factory->create($type); } return $this->_sharedInstances[$type]; } /** * Configure di instance * Note: All arguments should be pre-processed (sort order, translations, etc) before passing to method configure. * * @param array $configuration * @return void */ public function configure(array $configuration) { $this->_config->extend($configuration); } }