_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); } }