DynamicAsseticHelper.php 1.2 KB

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\Templating;
  11. use Assetic\Asset\AssetInterface;
  12. use Assetic\Factory\AssetFactory;
  13. use Symfony\Bundle\FrameworkBundle\Templating\Helper\RouterHelper;
  14. /**
  15. * The dynamic "assetic" templating helper.
  16. *
  17. * @author Kris Wallsmith <kris@symfony.com>
  18. */
  19. class DynamicAsseticHelper extends AsseticHelper
  20. {
  21. private $routerHelper;
  22. /**
  23. * Constructor.
  24. *
  25. * @param RouterHelper $routerHelper The router helper
  26. * @param AssetFactory $factory The asset factory
  27. * @param Boolean $debug The debug mode
  28. */
  29. public function __construct(RouterHelper $routerHelper, AssetFactory $factory, $debug = false)
  30. {
  31. $this->routerHelper = $routerHelper;
  32. parent::__construct($factory, $debug);
  33. }
  34. protected function getAssetUrl(AssetInterface $asset, $options = array())
  35. {
  36. return $this->routerHelper->generate('_assetic_'.$options['name']);
  37. }
  38. }