[FrameworkBundle] Add a new ClassCache cache warmer
This commit is contained in:
parent
72c6c61dbe
commit
b570d6cd8c
@ -0,0 +1,49 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
|
||||
|
||||
use Symfony\Component\ClassLoader\ClassCollectionLoader;
|
||||
use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
|
||||
|
||||
/**
|
||||
* Generates the Class Cache (classes.php) file.
|
||||
*
|
||||
* @author Tugdual Saunier <tucksaun@gmail.com>
|
||||
*/
|
||||
class ClassCacheCacheWarmer implements CacheWarmerInterface
|
||||
{
|
||||
/**
|
||||
* Warms up the cache.
|
||||
*
|
||||
* @param string $cacheDir The cache directory
|
||||
*/
|
||||
public function warmUp($cacheDir)
|
||||
{
|
||||
$classmap = $cacheDir.'/classes.map';
|
||||
|
||||
if (!is_file($classmap)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ClassCollectionLoader::load(include($classmap), $cacheDir, 'classes', false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether this warmer is optional or not.
|
||||
*
|
||||
* @return bool always true
|
||||
*/
|
||||
public function isOptional()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
@ -34,6 +34,10 @@
|
||||
<argument type="collection" />
|
||||
</service>
|
||||
|
||||
<service id="kernel.class_cache.cache_warmer" class="Symfony\Bundle\FrameworkBundle\CacheWarmer\ClassCacheCacheWarmer">
|
||||
<tag name="kernel.cache_warmer" />
|
||||
</service>
|
||||
|
||||
<service id="cache_clearer" class="%cache_clearer.class%">
|
||||
<argument type="collection" />
|
||||
</service>
|
||||
|
Reference in New Issue
Block a user