function ContainerBuilder::doResolveServices
3 calls to ContainerBuilder::doResolveServices()
- ContainerBuilder::callMethod in vendor/
symfony/ dependency-injection/ ContainerBuilder.php - ContainerBuilder::createService in vendor/
symfony/ dependency-injection/ ContainerBuilder.php - Creates a service for a service definition.
- ContainerBuilder::resolveServices in vendor/
symfony/ dependency-injection/ ContainerBuilder.php - Replaces service references by the real service instance and evaluates expressions.
File
-
vendor/
symfony/ dependency-injection/ ContainerBuilder.php, line 1256
Class
- ContainerBuilder
- ContainerBuilder is a DI container that provides an API to easily describe services.
Namespace
Symfony\Component\DependencyInjectionCode
private function doResolveServices(mixed $value, array &$inlineServices = [], bool $isConstructorArgument = false) : mixed {
if (\is_array($value)) {
foreach ($value as $k => $v) {
$value[$k] = $this->doResolveServices($v, $inlineServices, $isConstructorArgument);
}
}
elseif ($value instanceof ServiceClosureArgument) {
$reference = $value->getValues()[0];
$value = fn() => $this->resolveServices($reference);
}
elseif ($value instanceof IteratorArgument) {
$value = new RewindableGenerator(function () use ($value, &$inlineServices) {
foreach ($value->getValues() as $k => $v) {
foreach (self::getServiceConditionals($v) as $s) {
if (!$this->has($s)) {
continue 2;
}
}
foreach (self::getInitializedConditionals($v) as $s) {
if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE, $inlineServices)) {
continue 2;
}
}
(yield $k => $this->doResolveServices($v, $inlineServices));
}
}, function () use ($value) : int {
$count = 0;
foreach ($value->getValues() as $v) {
foreach (self::getServiceConditionals($v) as $s) {
if (!$this->has($s)) {
continue 2;
}
}
foreach (self::getInitializedConditionals($v) as $s) {
if (!$this->doGet($s, ContainerInterface::IGNORE_ON_UNINITIALIZED_REFERENCE)) {
continue 2;
}
}
++$count;
}
return $count;
});
}
elseif ($value instanceof ServiceLocatorArgument) {
$refs = $types = [];
foreach ($value->getValues() as $k => $v) {
$refs[$k] = [
$v,
null,
];
$types[$k] = $v instanceof TypedReference ? $v->getType() : '?';
}
$value = new ServiceLocator($this->resolveServices(...), $refs, $types);
}
elseif ($value instanceof Reference) {
$value = $this->doGet((string) $value, $value->getInvalidBehavior(), $inlineServices, $isConstructorArgument);
}
elseif ($value instanceof Definition) {
$value = $this->createService($value, $inlineServices, $isConstructorArgument);
}
elseif ($value instanceof Parameter) {
$value = $this->getParameter((string) $value);
}
elseif ($value instanceof Expression) {
$value = $this->getExpressionLanguage()
->evaluate($value, [
'container' => $this,
]);
}
elseif ($value instanceof AbstractArgument) {
throw new RuntimeException($value->getTextWithContext());
}
return $value;
}