ClassCacheCacheWarmer.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\FrameworkBundle\CacheWarmer;
  11. use Symfony\Component\ClassLoader\ClassCollectionLoader;
  12. use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
  13. /**
  14. * Generates the Class Cache (classes.php) file.
  15. *
  16. * @author Tugdual Saunier <tucksaun@gmail.com>
  17. */
  18. class ClassCacheCacheWarmer implements CacheWarmerInterface
  19. {
  20. /**
  21. * Warms up the cache.
  22. *
  23. * @param string $cacheDir The cache directory
  24. */
  25. public function warmUp($cacheDir)
  26. {
  27. $classmap = $cacheDir.'/classes.map';
  28. if (!is_file($classmap)) {
  29. return;
  30. }
  31. if (file_exists($cacheDir.'/classes.php')) {
  32. return;
  33. }
  34. ClassCollectionLoader::load(include($classmap), $cacheDir, 'classes', false);
  35. }
  36. /**
  37. * Checks whether this warmer is optional or not.
  38. *
  39. * @return bool always true
  40. */
  41. public function isOptional()
  42. {
  43. return true;
  44. }
  45. }