/
githubmirror
/
magento2
Обзор
Документация
Войти
/
githubmirror
/
magento2
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
2.4-develop
lib/internal/Magento/Framework/ObjectManager/ObjectManager.php
101 строка
3 KB
Alexandra Zota
ACP2E-4019: CE copyright updates for 2.4.9-beta1
22 окт 2025, 17:47
22 окт 2025, 17:47
1b769b7
Код
Авторство
О чём код?
<?php /** * Copyright 2014 Adobe * All Rights Reserved. */ namespace Magento\Framework\ObjectManager; /** * 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 * */ 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; /** * phpcs:disable Magento2.Annotation.MethodArguments.VisualAlignment * @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); } /** * Disable show ObjectManager internals with var_dump * * @see https://www.php.net/manual/en/language.oop5.magic.php#object.debuginfo * @return array */ public function __debugInfo() { return []; } }