Skip to content

Commit 2329a75

Browse files
magnetikTobion
authored andcommitted
Migration annotations configuration to PHP
1 parent 7bc1df6 commit 2329a75

File tree

3 files changed

+66
-58
lines changed

3 files changed

+66
-58
lines changed

DependencyInjection/FrameworkExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,7 @@ public function load(array $configs, ContainerBuilder $container)
373373
$this->registerWorkflowConfiguration($config['workflows'], $container, $loader);
374374
$this->registerDebugConfiguration($config['php_errors'], $container, $phpLoader);
375375
$this->registerRouterConfiguration($config['router'], $container, $phpLoader, $config['translator']['enabled_locales'] ?? []);
376-
$this->registerAnnotationsConfiguration($config['annotations'], $container, $loader);
376+
$this->registerAnnotationsConfiguration($config['annotations'], $container, $phpLoader);
377377
$this->registerPropertyAccessConfiguration($config['property_access'], $container, $phpLoader);
378378
$this->registerSecretsConfiguration($config['secrets'], $container, $phpLoader);
379379

@@ -1331,7 +1331,7 @@ private function registerAnnotationsConfiguration(array $config, ContainerBuilde
13311331
throw new LogicException('Annotations cannot be enabled as the Doctrine Annotation library is not installed.');
13321332
}
13331333

1334-
$loader->load('annotations.xml');
1334+
$loader->load('annotations.php');
13351335

13361336
if (!method_exists(AnnotationRegistry::class, 'registerUniqueLoader')) {
13371337
$container->getDefinition('annotations.dummy_registry')

Resources/config/annotations.php

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\DependencyInjection\Loader\Configurator;
13+
14+
use Doctrine\Common\Annotations\AnnotationReader;
15+
use Doctrine\Common\Annotations\AnnotationRegistry;
16+
use Doctrine\Common\Annotations\CachedReader;
17+
use Doctrine\Common\Annotations\Reader;
18+
use Doctrine\Common\Cache\ArrayCache;
19+
use Doctrine\Common\Cache\FilesystemCache;
20+
use Symfony\Bundle\FrameworkBundle\CacheWarmer\AnnotationsCacheWarmer;
21+
use Symfony\Component\Cache\Adapter\PhpArrayAdapter;
22+
use Symfony\Component\Cache\DoctrineProvider;
23+
24+
return static function (ContainerConfigurator $container) {
25+
$container->services()
26+
->set('annotations.reader', AnnotationReader::class)
27+
->call('addGlobalIgnoredName', ['', service('annotations.dummy_registry')])
28+
29+
->set('annotations.dummy_registry', AnnotationRegistry::class)
30+
->call('registerUniqueLoader', ['class_exists'])
31+
32+
->set('annotations.cached_reader', CachedReader::class)
33+
->args([
34+
service('annotations.reader'),
35+
inline_service(ArrayCache::class),
36+
abstract_arg('debug flag'),
37+
])
38+
39+
->set('annotations.filesystem_cache', FilesystemCache::class)
40+
->args([
41+
abstract_arg('cache-directory'),
42+
])
43+
44+
->set('annotations.cache_warmer', AnnotationsCacheWarmer::class)
45+
->args([
46+
service('annotations.reader'),
47+
param('kernel.cache_dir').'/annotations.php',
48+
'#^Symfony\\(?:Component\\HttpKernel\\|Bundle\\FrameworkBundle\\Controller\\(?!.*Controller$))#',
49+
param('kernel.debug'),
50+
])
51+
52+
->set('annotations.cache', DoctrineProvider::class)
53+
->args([
54+
inline_service()
55+
->factory([PhpArrayAdapter::class, 'create'])
56+
->args([
57+
param('kernel.cache_dir').'/annotations.php',
58+
service('cache.annotations'),
59+
]),
60+
])
61+
62+
->alias('annotation_reader', 'annotations.reader')
63+
->alias(Reader::class, 'annotation_reader');
64+
};

Resources/config/annotations.xml

Lines changed: 0 additions & 56 deletions
This file was deleted.

0 commit comments

Comments
 (0)