added checks for public services on compiler passes that use service id and not references
This commit is contained in:
parent
470dc3e36f
commit
996c1ee3cb
@ -28,7 +28,17 @@ class AddConstraintValidatorsPass implements CompilerPassInterface
|
|||||||
$validators[$attributes[0]['alias']] = $id;
|
$validators[$attributes[0]['alias']] = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$validators[$container->getDefinition($id)->getClass()] = $id;
|
$definition = $container->getDefinition($id);
|
||||||
|
|
||||||
|
if (!$definition->isPublic()) {
|
||||||
|
throw new InvalidArgumentException(sprintf('The service "%s" must be public as it can be lazy-loaded.', $id));
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($definition->isAbstract()) {
|
||||||
|
throw new InvalidArgumentException(sprintf('The service "%s" must not be abstract as it can be lazy-loaded.', $id));
|
||||||
|
}
|
||||||
|
|
||||||
|
$validators[$definition->getClass()] = $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
$container->getDefinition('validator.validator_factory')->replaceArgument(1, $validators);
|
$container->getDefinition('validator.validator_factory')->replaceArgument(1, $validators);
|
||||||
|
@ -75,7 +75,7 @@ class FrameworkBundle extends Bundle
|
|||||||
// but as late as possible to get resolved parameters
|
// but as late as possible to get resolved parameters
|
||||||
$container->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
$container->addCompilerPass(new RegisterListenersPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||||
$container->addCompilerPass(new TemplatingPass());
|
$container->addCompilerPass(new TemplatingPass());
|
||||||
$container->addCompilerPass(new AddConstraintValidatorsPass());
|
$container->addCompilerPass(new AddConstraintValidatorsPass(), PassConfig::TYPE_BEFORE_REMOVING);
|
||||||
$container->addCompilerPass(new AddValidatorInitializersPass());
|
$container->addCompilerPass(new AddValidatorInitializersPass());
|
||||||
$container->addCompilerPass(new AddConsoleCommandPass());
|
$container->addCompilerPass(new AddConsoleCommandPass());
|
||||||
$container->addCompilerPass(new FormPass());
|
$container->addCompilerPass(new FormPass());
|
||||||
|
Reference in New Issue
Block a user