[FrameworkBundle] Fine-tune generated annotations.php cache
This commit is contained in:
parent
8cd2193a82
commit
d36adc2392
@ -27,16 +27,18 @@ use Symfony\Component\Cache\DoctrineProvider;
|
|||||||
class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer
|
class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer
|
||||||
{
|
{
|
||||||
private $annotationReader;
|
private $annotationReader;
|
||||||
|
private $excludeRegexp;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Reader $annotationReader
|
* @param Reader $annotationReader
|
||||||
* @param string $phpArrayFile The PHP file where annotations are cached
|
* @param string $phpArrayFile The PHP file where annotations are cached
|
||||||
* @param CacheItemPoolInterface $fallbackPool The pool where runtime-discovered 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);
|
parent::__construct($phpArrayFile, $fallbackPool);
|
||||||
$this->annotationReader = $annotationReader;
|
$this->annotationReader = $annotationReader;
|
||||||
|
$this->excludeRegexp = $excludeRegexp;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,6 +56,9 @@ class AnnotationsCacheWarmer extends AbstractPhpFileCacheWarmer
|
|||||||
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter));
|
$reader = new CachedReader($this->annotationReader, new DoctrineProvider($arrayAdapter));
|
||||||
|
|
||||||
foreach ($annotatedClasses as $class) {
|
foreach ($annotatedClasses as $class) {
|
||||||
|
if (null !== $this->excludeRegexp && preg_match($this->excludeRegexp, $class)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
$this->readAllComponents($reader, $class);
|
$this->readAllComponents($reader, $class);
|
||||||
} catch (\ReflectionException $e) {
|
} catch (\ReflectionException $e) {
|
||||||
|
@ -310,6 +310,7 @@ class FrameworkExtension extends Extension
|
|||||||
'**\\Entity\\',
|
'**\\Entity\\',
|
||||||
|
|
||||||
// Added explicitly so that we don't rely on the class map being dumped to make it work
|
// 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',
|
'Symfony\\Bundle\\FrameworkBundle\\Controller\\Controller',
|
||||||
));
|
));
|
||||||
|
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
<argument type="service" id="annotations.reader" />
|
<argument type="service" id="annotations.reader" />
|
||||||
<argument>%kernel.cache_dir%/annotations.php</argument>
|
<argument>%kernel.cache_dir%/annotations.php</argument>
|
||||||
<argument type="service" id="cache.annotations" />
|
<argument type="service" id="cache.annotations" />
|
||||||
|
<argument>#^Symfony\\(?:Component\\HttpKernel\\|Bundle\\FrameworkBundle\\Controller\\(?!AbstractController$|Controller$))#</argument>
|
||||||
</service>
|
</service>
|
||||||
|
|
||||||
<service id="annotations.cache" class="Symfony\Component\Cache\DoctrineProvider">
|
<service id="annotations.cache" class="Symfony\Component\Cache\DoctrineProvider">
|
||||||
|
Reference in New Issue
Block a user