89 $this->_relations = $relations ?: new \Magento\Framework\ObjectManager\Relations\Runtime();
90 $this->_definitions = $definitions ?: new \Magento\Framework\ObjectManager\Definition\Runtime();
101 $this->_relations = $relations;
123 if (isset($this->_mergedArguments[
$type])) {
124 return $this->_mergedArguments[
$type];
137 return !isset($this->_nonShared[
$type]);
148 while (isset($this->_virtualTypes[$instanceName])) {
149 $instanceName = $this->_virtualTypes[$instanceName];
151 return $instanceName;
164 $preferencePath = [];
165 while (isset($this->_preferences[
$type])) {
166 if (isset($preferencePath[$this->_preferences[
$type]])) {
167 throw new \LogicException(
168 'Circular type preference: ' .
171 $this->_preferences[
$type] .
176 $preferencePath[
$type] = 1;
190 if (!isset($this->_mergedArguments[
$type])) {
191 if (isset($this->_virtualTypes[
$type])) {
194 $relations = $this->_relations->getParents(
$type);
196 foreach ($relations as $relation) {
199 if ($relationArguments) {
208 if (isset($this->_arguments[
$type])) {
218 return $this->_mergedArguments[
$type];
233 foreach ($curConfig as $for => $to) {
234 $this->_preferences[ltrim($for,
'\\')] = ltrim($to,
'\\');
239 $key = ltrim($key,
'\\');
240 if (isset($curConfig[
'type'])) {
241 $this->_virtualTypes[$key] = ltrim($curConfig[
'type'],
'\\');
243 if (isset($curConfig[
'arguments'])) {
244 if (!empty($this->_mergedArguments)) {
245 $this->_mergedArguments = [];
247 if (isset($this->_arguments[$key])) {
248 $this->_arguments[$key] = array_replace($this->_arguments[$key], $curConfig[
'arguments']);
250 $this->_arguments[$key] = $curConfig[
'arguments'];
253 if (isset($curConfig[
'shared'])) {
254 if (!$curConfig[
'shared']) {
255 $this->_nonShared[$key] = 1;
257 unset($this->_nonShared[$key]);
274 if (!$this->_currentCacheKey) {
275 $this->_currentCacheKey = md5(
276 $this->getSerializer()->serialize(
277 [$this->_arguments, $this->_nonShared, $this->_preferences, $this->_virtualTypes]
281 $key = md5($this->_currentCacheKey . $this->getSerializer()->serialize(
$configuration));
282 $cached = $this->_cache->get($key);
288 $this->_virtualTypes,
289 $this->_mergedArguments
293 if (!$this->_mergedArguments) {
294 foreach ($this->_definitions->getClasses() as
$class) {
303 $this->_virtualTypes,
304 $this->_mergedArguments,
309 $this->_currentCacheKey = $key;
341 private function getSerializer()
343 if ($this->serializer ===
null) {
345 ->get(SerializerInterface::class);
347 return $this->serializer;
_mergeConfiguration(array $configuration)
setCache(ConfigCacheInterface $cache)
elseif(isset( $params[ 'redirect_parent']))
setRelations(RelationsInterface $relations)
$_option $_optionId $class
getInstanceType($instanceName)
__construct(RelationsInterface $relations=null, DefinitionInterface $definitions=null)
extend(array $configuration)
_collectConfiguration($type)