DynamicAsseticHelper.php 1.1KB

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. */
  28. public function __construct(RouterHelper $routerHelper, AssetFactory $factory)
  29. {
  30. $this->routerHelper = $routerHelper;
  31. parent::__construct($factory);
  32. }
  33. protected function getAssetUrl(AssetInterface $asset, $options = array())
  34. {
  35. return $this->routerHelper->generate('_assetic_'.$options['name']);
  36. }
  37. }