RoutesCacheWarmUp.php 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * This file is part of the Sonata project.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\AdminBundle\Route;
  11. use Sonata\AdminBundle\Admin\Pool;
  12. use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
  13. class RoutesCacheWarmUp implements CacheWarmerInterface
  14. {
  15. protected $cache;
  16. protected $pool;
  17. /**
  18. * @param RoutesCache $cache
  19. * @param Pool $pool
  20. */
  21. public function __construct(RoutesCache $cache, Pool $pool)
  22. {
  23. $this->cache = $cache;
  24. $this->pool = $pool;
  25. }
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function isOptional()
  30. {
  31. true;
  32. }
  33. /**
  34. * {@inheritdoc}
  35. */
  36. public function warmUp($cacheDir)
  37. {
  38. foreach ($this->pool->getAdminServiceIds() as $id) {
  39. $this->cache->load($this->pool->getInstance($id));
  40. }
  41. }
  42. }