Skip to content

Commit

Permalink
minor #24880 [FrameworkBundle] Fine-tune generated annotations.php ca…
Browse files Browse the repository at this point in the history
…che (nicolas-grekas)

This PR was merged into the 3.4 branch.

Discussion
----------

[FrameworkBundle] Fine-tune generated annotations.php cache

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

I noticed that the `annotations.php` file generated by `AnnotationsCacheWarmer` contains some noise.
This PR removes it.

Commits
-------

d36adc2 [FrameworkBundle] Fine-tune generated annotations.php cache
  • Loading branch information
fabpot committed Nov 9, 2017
2 parents 8cd2193 + d36adc2 commit bd0899e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Expand Up @@ -27,16 +27,18 @@
class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer
{
private $annotationReader;
private $excludeRegexp;

/**
* @param Reader $annotationReader
* @param string $phpArrayFile The PHP file where annotations are cached
* @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered annotations are cached
*/
public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPoolInterface $fallbackPool)
public function __construct(Reader $annotationReader, $phpArrayFile, CacheItemPoolInterface $fallbackPool, $excludeRegexp = null)
{
parent::__construct($phpArrayFile, $fallbackPool);
$this->annotationReader = $annotationReader;
$this->excludeRegexp = $excludeRegexp;
}

/**
Expand All @@ -54,6 +56,9 @@ protected function doWarmUp($cacheDir, ArrayAdapter $arrayAdapter)
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter));

foreach ($annotatedClasses as $class) {
if (null !== $this->excludeRegexp && preg_match($this->excludeRegexp, $class)) {
continue;
}
try {
$this->readAllComponents($reader, $class);
} catch (\ReflectionException $e) {
Expand Down
Expand Up @@ -310,6 +310,7 @@ public function load(array $configs, ContainerBuilder $container)
'**\\Entity\\',

// Added explicitly so that we don't rely on the class map being dumped to make it work
'Symfony\\Bundle\\FrameworkBundle\\Controller\\AbstractController',
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
));

Expand Down
Expand Up @@ -37,6 +37,7 @@
<argument type="service" id="annotations.reader" />
<argument>%kernel.cache_dir%/annotations.php</argument>
<argument type="service" id="cache.annotations" />
<argument>#^Symfony\\(?:Component\\HttpKernel\\|Bundle\\FrameworkBundle\\Controller\\(?!AbstractController$|Controller$))#</argument>
</service>

<service id="annotations.cache" class="Symfony\Component\Cache\DoctrineProvider">
Expand Down

0 comments on commit bd0899e

Please sign in to comment.