/** * * @param InjectorInterface $injector * @return mixed * @throws InjectorException */ public final function resolve(InjectorInterface $injector) { try { return $this->getInstance($injector); } catch (Exception $exception) { $name = $this->getName(); throw new InjectorException(InjectorException::getDefinitionInjectionFailedMessage($name), null, $exception); } }
/** * * @param ParameterInterface $parameter * @param array $nameValueMap * @param DefinitionInterface[] $eachDefinition * @return array * @throws InjectorException */ private function resolveParameter(ParameterInterface $parameter, array $nameValueMap, $eachDefinition) { $name = $parameter->getName(); if (isset($nameValueMap[$name])) { return $nameValueMap[$name]; } if ($parameter->hasClassName()) { $className = $parameter->getClassName(); return $this->withEachDefinition($eachDefinition)->create($className); } if ($parameter->hasDefaultValue()) { return $parameter->getDefaultValue(); } throw new InjectorException(InjectorException::getParameterInjectionFailedMessage($name), null); }