[FrameworkBundle] Configure PHP Attributes without doctrine/annotations.

This commit is contained in:
Alexander M. Turek 2020-11-06 02:06:52 +01:00
parent 5c5b8d61ee
commit e5492e2e55
3 changed files with 6 additions and 6 deletions

View File

@ -965,11 +965,11 @@ class FrameworkExtension extends Extension
->replaceArgument(0, $config['default_uri']);
}
if ($this->annotationsConfigEnabled) {
if (\PHP_VERSION_ID >= 80000 || $this->annotationsConfigEnabled) {
$container->register('routing.loader.annotation', AnnotatedRouteControllerLoader::class)
->setPublic(false)
->addTag('routing.loader', ['priority' => -10])
->addArgument(new Reference('annotation_reader'));
->addArgument(new Reference('annotation_reader', ContainerInterface::NULL_ON_INVALID_REFERENCE));
$container->register('routing.loader.annotation.directory', AnnotationDirectoryLoader::class)
->setPublic(false)
@ -1564,13 +1564,13 @@ class FrameworkExtension extends Extension
$serializerLoaders = [];
if (isset($config['enable_annotations']) && $config['enable_annotations']) {
if (!$this->annotationsConfigEnabled) {
if (\PHP_VERSION_ID < 80000 && !$this->annotationsConfigEnabled) {
throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
}
$annotationLoader = new Definition(
'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
[new Reference('annotation_reader')]
[new Reference('annotation_reader', ContainerInterface::NULL_ON_INVALID_REFERENCE)]
);
$annotationLoader->setPublic(false);

View File

@ -1232,7 +1232,7 @@ abstract class FrameworkExtensionTest extends TestCase
$projectDir = $container->getParameter('kernel.project_dir');
$configDir = __DIR__.'/Fixtures/TestBundle/Resources/config';
$expectedLoaders = [
new Definition(AnnotationLoader::class, [new Reference('annotation_reader')]),
new Definition(AnnotationLoader::class, [new Reference('annotation_reader', ContainerInterface::NULL_ON_INVALID_REFERENCE)]),
new Definition(XmlFileLoader::class, [$configDir.'/serialization.xml']),
new Definition(YamlFileLoader::class, [$configDir.'/serialization.yml']),
new Definition(YamlFileLoader::class, [$projectDir.'/config/serializer/foo.yml']),

View File

@ -29,7 +29,7 @@
"symfony/polyfill-php80": "^1.15",
"symfony/filesystem": "^4.4|^5.0",
"symfony/finder": "^4.4|^5.0",
"symfony/routing": "^5.1"
"symfony/routing": "^5.2"
},
"require-dev": {
"doctrine/annotations": "~1.7",