/** * @codeCoverageIgnore */ public function __toString() { if ($this->lazy) { return sprintf('Binding listener [lazy]: %s->%s()', $this->binding->getTypeName(), $this->methodName); } return sprintf('Binding listener: %s->%s()', $this->binding->getTypeName(), $this->methodName); }
/** * {@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); }); }
/** * Register a binding in the locator, will use the name of the bound type when no * name for the service is given. * * @param BindingInterface $binding The binding being used to load the service. * @param string $name Optional name of the registered service. * * @throws DuplicateServiceRegistrationException */ public function registerService(BindingInterface $binding, $name = NULL) { $key = $name === NULL ? $binding->getTypeName() : (string) $name; if (isset($this->bindings[$key])) { throw new DuplicateServiceRegistrationException(sprintf('Service "%s" is already registered', $key)); } $this->bindings[$key] = $binding; }