RouterCacheWarmer.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\HttpKernel\CacheWarmer\CacheWarmerInterface;
  12. use Symfony\Component\HttpKernel\CacheWarmer\WarmableInterface;
  13. use Symfony\Component\Routing\RouterInterface;
  14. /**
  15. * Generates the router matcher and generator classes.
  16. *
  17. * @author Fabien Potencier <fabien@symfony.com>
  18. */
  19. class RouterCacheWarmer implements CacheWarmerInterface
  20. {
  21. protected $router;
  22. public function __construct(RouterInterface $router)
  23. {
  24. $this->router = $router;
  25. }
  26. /**
  27. * Warms up the cache.
  28. *
  29. * @param string $cacheDir The cache directory
  30. */
  31. public function warmUp($cacheDir)
  32. {
  33. if ($this->router instanceof WarmableInterface) {
  34. $this->router->warmUp($cacheDir);
  35. }
  36. }
  37. /**
  38. * Checks whether this warmer is optional or not.
  39. *
  40. * @return bool always true
  41. */
  42. public function isOptional()
  43. {
  44. return true;
  45. }
  46. }