|
| 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 | +}; |
0 commit comments