/** * {@inheritdoc} */ public function getBound(BindingInterface $binding, InjectionPointInterface $point = NULL) { if (!$binding instanceof DelegateBinding) { return $this->get($binding->getTypeName(), $point); } $scope = $binding->getScope(); if ($scope === NULL) { return $binding($this, $point); } $name = $binding->getTypeName(); if (isset($this->proxies[$name])) { return $this->proxies[$name]; } if (empty($this->scopes[$scope])) { throw new ScopeNotFoundException(sprintf('Scope %s of %s not found', $scope, $name)); } if ($this->scopes[$scope] instanceof ProxyScopeManagerInterface) { return $this->proxies[$name] = $this->scopes[$scope]->createProxy($binding, $this); } return $this->proxies[$name] = $this->scopes[$scope]->lookup($name, function () use($binding) { return $binding($this); }); }
/** * {@inheritdoc} */ public function getBound(BindingInterface $binding, InjectionPointInterface $point = NULL) { $scope = $binding->getScope(); if ($scope === NULL) { switch ($binding->getOptions() & BindingInterface::MASK_TYPE) { case BindingInterface::TYPE_ALIAS: return $this->get($binding->getTarget(), $point); case BindingInterface::TYPE_FACTORY: case BindingInterface::TYPE_FACTORY_ALIAS: return $this->createObjectUsingFactory($binding, $point); default: return $this->createObject($binding->getTarget(), $binding->getResolvers(), $binding->getInitializers(), $binding->getMarkers(SetterInjection::class)); } } $name = $binding->getTypeName(); if (isset($this->proxies[$name])) { return $this->proxies[$name]; } if (empty($this->scopes[$scope])) { throw new ScopeNotFoundException(sprintf('Scope %s of %s not found', $scope, $name)); } if ($this->scopes[$scope] instanceof ProxyScopeManagerInterface) { return $this->proxies[$name] = $this->scopes[$scope]->createProxy($binding, $this); } switch ($binding->getOptions() & BindingInterface::MASK_TYPE) { case BindingInterface::TYPE_FACTORY: case BindingInterface::TYPE_FACTORY_ALIAS: return $this->proxies[$name] = $this->scopes[$scope]->lookup($name, function () use($binding) { return $this->createObjectUsingFactory($binding); }); default: return $this->proxies[$name] = $this->scopes[$scope]->lookup($name, function () use($binding) { return $this->createObject($binding->getTarget(), $binding->getResolvers(), $binding->getInitializers(), $binding->getMarkers(SetterInjection::class)); }); } }