AssetWriterCacheWarmer.php 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. /*
  3. * This file is part of the Symfony framework.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * This source file is subject to the MIT license that is bundled
  8. * with this source code in the file LICENSE.
  9. */
  10. namespace Symfony\Bundle\AsseticBundle\CacheWarmer;
  11. use Assetic\AssetWriter;
  12. use Symfony\Component\HttpKernel\CacheWarmer\CacheWarmerInterface;
  13. use Symfony\Component\DependencyInjection\ContainerInterface;
  14. /**
  15. * The AssetWriterCacheWarmer processes and writes the asset files.
  16. *
  17. * @author Kris Wallsmith <kris@symfony.com>
  18. */
  19. class AssetWriterCacheWarmer implements CacheWarmerInterface
  20. {
  21. private $container;
  22. private $writer;
  23. public function __construct(ContainerInterface $container, AssetWriter $writer)
  24. {
  25. $this->container = $container;
  26. $this->writer = $writer;
  27. }
  28. public function warmUp($cacheDir)
  29. {
  30. $am = $this->container->get('assetic.asset_manager');
  31. $this->writer->writeManagerAssets($am);
  32. }
  33. public function isOptional()
  34. {
  35. return true;
  36. }
  37. }