function CheckExceptionOnInvalidReferenceBehaviorPass::processValue
Overrides AbstractRecursivePass::processValue
File
-
vendor/
symfony/ dependency-injection/ Compiler/ CheckExceptionOnInvalidReferenceBehaviorPass.php, line 45
Class
- CheckExceptionOnInvalidReferenceBehaviorPass
- Checks that all references are pointing to a valid service.
Namespace
Symfony\Component\DependencyInjection\CompilerCode
protected function processValue(mixed $value, bool $isRoot = false) : mixed {
if (!$value instanceof Reference) {
return parent::processValue($value, $isRoot);
}
if (ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $value->getInvalidBehavior() || $this->container
->has((string) $value)) {
return $value;
}
$currentId = $this->currentId;
$graph = $this->container
->getCompiler()
->getServiceReferenceGraph();
if (isset($this->serviceLocatorContextIds[$currentId])) {
$currentId = $this->serviceLocatorContextIds[$currentId];
$locator = $this->container
->getDefinition($this->currentId)
->getFactory()[0];
$this->throwServiceNotFoundException($value, $currentId, $locator->getArgument(0));
}
if ('.' === $currentId[0] && $graph->hasNode($currentId)) {
foreach ($graph->getNode($currentId)
->getInEdges() as $edge) {
if (!$edge->getValue() instanceof Reference || ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE < $edge->getValue()
->getInvalidBehavior()) {
continue;
}
$sourceId = $edge->getSourceNode()
->getId();
if ('.' !== $sourceId[0]) {
$currentId = $sourceId;
break;
}
if (isset($this->serviceLocatorContextIds[$sourceId])) {
$currentId = $this->serviceLocatorContextIds[$sourceId];
$locator = $this->container
->getDefinition($this->currentId);
$this->throwServiceNotFoundException($value, $currentId, $locator->getArgument(0));
}
}
}
$this->throwServiceNotFoundException($value, $currentId, $value);
}