function AbstractConfigurator::processValue
Checks that a value is valid, optionally replacing Definition and Reference configurators by their configure value.
Parameters
bool $allowServices whether Definition and Reference are allowed; by default, only scalars, arrays and enum are:
Return value
mixed the value, optionally cast to a Definition/Reference
5 calls to AbstractConfigurator::processValue()
- ContainerConfigurator::extension in vendor/
symfony/ dependency-injection/ Loader/ Configurator/ ContainerConfigurator.php - iterator in vendor/
symfony/ dependency-injection/ Loader/ Configurator/ ContainerConfigurator.php - Creates a lazy iterator.
- ParametersConfigurator::set in vendor/
symfony/ dependency-injection/ Loader/ Configurator/ ParametersConfigurator.php - ServicesConfigurator::alias in vendor/
symfony/ dependency-injection/ Loader/ Configurator/ ServicesConfigurator.php - Creates an alias.
- service_locator in vendor/
symfony/ dependency-injection/ Loader/ Configurator/ ContainerConfigurator.php - Creates a service locator.
File
-
vendor/
symfony/ dependency-injection/ Loader/ Configurator/ AbstractConfigurator.php, line 63
Class
Namespace
Symfony\Component\DependencyInjection\Loader\ConfiguratorCode
public static function processValue(mixed $value, bool $allowServices = false) : mixed {
if (\is_array($value)) {
foreach ($value as $k => $v) {
$value[$k] = static::processValue($v, $allowServices);
}
return self::$valuePreProcessor ? (self::$valuePreProcessor)($value, $allowServices) : $value;
}
if (self::$valuePreProcessor) {
$value = (self::$valuePreProcessor)($value, $allowServices);
}
if ($value instanceof ReferenceConfigurator) {
$reference = new Reference($value->id, $value->invalidBehavior);
return $value instanceof ClosureReferenceConfigurator ? new ServiceClosureArgument($reference) : $reference;
}
if ($value instanceof InlineServiceConfigurator) {
$def = $value->definition;
$value->definition = null;
return $def;
}
if ($value instanceof ParamConfigurator) {
return (string) $value;
}
if ($value instanceof self) {
throw new InvalidArgumentException(\sprintf('"%s()" can be used only at the root of service configuration files.', $value::FACTORY));
}
switch (true) {
case null === $value:
case \is_scalar($value):
case $value instanceof \UnitEnum:
return $value;
case $value instanceof ArgumentInterface:
case $value instanceof Definition:
case $value instanceof Expression:
case $value instanceof Parameter:
case $value instanceof AbstractArgument:
case $value instanceof Reference:
if ($allowServices) {
return $value;
}
}
throw new InvalidArgumentException(\sprintf('Cannot use values of type "%s" in service configuration files.', get_debug_type($value)));
}