Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7b4d22f

Browse files
committed
feature #39022 [FrameworkBundle] Allow to use attribute-based configuration of routing/serializer without doctrine/annotations (derrabus)
This PR was merged into the 5.2-dev branch. Discussion ---------- [FrameworkBundle] Allow to use attribute-based configuration of routing/serializer without doctrine/annotations | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | no | New feature? | yes | Deprecations? | no | Tickets | N/A | License | MIT | Doc PR | N/A Follows #37474, #38525 Currently, we need `doctrine/annotations` to be installed in order to configure routing and serializer via PHP attributes. Given that for both components we can already replace Doctrine Annotations completely, I'd like to get rid of that limitation. Commits ------- e5492e2 [FrameworkBundle] Configure PHP Attributes without doctrine/annotations.
2 parents 50c7c3d + e5492e2 commit 7b4d22f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -965,11 +965,11 @@ private function registerRouterConfiguration(array $config, ContainerBuilder $co
965965
->replaceArgument(0, $config['default_uri']);
966966
}
967967

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

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

15651565
$serializerLoaders = [];
15661566
if (isset($config['enable_annotations']) && $config['enable_annotations']) {
1567-
if (!$this->annotationsConfigEnabled) {
1567+
if (\PHP_VERSION_ID < 80000 && !$this->annotationsConfigEnabled) {
15681568
throw new \LogicException('"enable_annotations" on the serializer cannot be set as Annotations support is disabled.');
15691569
}
15701570

15711571
$annotationLoader = new Definition(
15721572
'Symfony\Component\Serializer\Mapping\Loader\AnnotationLoader',
1573-
[new Reference('annotation_reader')]
1573+
[new Reference('annotation_reader', ContainerInterface::NULL_ON_INVALID_REFERENCE)]
15741574
);
15751575
$annotationLoader->setPublic(false);
15761576

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)