8000 [FrameworkBundle] Allow to use attribute-based configuration of routi… · symfony/symfony@48eac5e · GitHub
[go: up one dir, main page]

Skip to content

Commit 48eac5e

Browse files
committed
[FrameworkBundle] Allow to use attribute-based configuration of routing/serializer without doctrine/annotations.
1 parent 2c39acd commit 48eac5e

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@
140140
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface;
141141
use Symfony\Component\Serializer\Encoder\DecoderInterface;
142142
use Symfony\Component\Serializer\Encoder\EncoderInterface;
143+
use Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader;
143144
use Symfony\Component\Serializer\Normalizer\DenormalizerInterface;
144145
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
145146
use Symfony\Component\Serializer\Normalizer\UnwrappingDenormalizer;
@@ -965,11 +966,11 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
965966
->replaceArgument(0, $config['default_uri']);
966967
}
967968

968-
if ($this->annotationsConfigEnabled) {
969+
if (\PHP_VERSION_ID >= 80000 || $this->annotationsConfigEnabled) {
969970
$container->register('routing.loader.annotation', AnnotatedRouteControllerLoader::class)
970971
->setPublic(false)
971972
->addTag('routing.loader', ['priority' => -10])
972-
->addArgument(new Reference('annotation_reader'));
973+
->addArgument(new Reference('annotation_reader', ContainerInterface::NULL_ON_INVALID_REFERENCE));
973974

974975
$container->register('routing.loader.annotation.directory', AnnotationDirectoryLoader::class)
975976
->setPublic(false)
@@ -1564,13 +1565,13 @@ private function registerSerializerConfiguration(array $config, ContainerBuilder
15641565

15651566
$serializerLoaders = [];
15661567
if (isset($config['enable_annotations']) && $config['enable_annotations']) {
1567-
if (!$this->annotationsConfigEnabled) {
1568+
if (\PHP_VERSION_ID < 80000 && !$this->annotationsConfigEnabled) {
15681569
throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
15691570
}
15701571

15711572
$annotationLoader = new Definition(
1572-
'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
1573-
[new Reference('annotation_reader')]
1573+
AnnotationLoader::class,
1574+
[new Reference('annotation_reader', ContainerInterface::NULL_ON_INVALID_REFERENCE)]
15741575
);
15751576
$annotationLoader->setPublic(false);
15761577

src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/FrameworkExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1232,7 +1232,7 @@ public function testSerializerMapping()
12321232
$projectDir = $container->getParameter('kernel.project_dir');
12331233
$configDir = __DIR__.'/Fixtures/TestBundle/Resources/config';
12341234
$expectedLoaders = [
1235-
new Definition(AnnotationLoader::class, [new Reference('annotation_reader')]),
1235+
new Definition(AnnotationLoader::class, [new Reference('annotation_reader', ContainerInterface::NULL_ON_INVALID_REFERENCE)]),
12361236
new Definition(XmlFileLoader::class, [$configDir.'/serialization.xml']),
12371237
new Definition(YamlFileLoader::class, [$configDir.'/serialization.yml']),
12381238
new Definition(YamlFileLoader::class, [$projectDir.'/config/serializer/foo.yml']),

src/Symfony/Bundle/FrameworkBundle/composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"symfony/polyfill-php80": "^1.15",
3030
"symfony/filesystem": "^4.4|^5.0",
3131
"symfony/finder": "^4.4|^5.0",
32-
"symfony/routing": "^5.1"
32+
"symfony/routing": "^5.2"
3333
},
3434
"require-dev": {
3535
"doctrine/annotations": "~1.7",

0 commit comments

Comments
 (0)
0