StaticAsseticHelper.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\Component\Templating\Helper\AssetsHelper;
  14. /**
  15. * The static "assetic" templating helper.
  16. *
  17. * @author Kris Wallsmith <kris@symfony.com>
  18. */
  19. class StaticAsseticHelper extends AsseticHelper
  20. {
  21. private $assetsHelper;
  22. /**
  23. * Constructor.
  24. *
  25. * @param AssetsHelper $assetsHelper The assets helper
  26. * @param AssetFactory $factory The asset factory
  27. * @param Boolean $debug The debug mode
  28. */
  29. public function __construct(AssetsHelper $assetsHelper, AssetFactory $factory, $debug = false)
  30. {
  31. $this->assetsHelper = $assetsHelper;
  32. parent::__construct($factory, $debug);
  33. }
  34. protected function getAssetUrl(AssetInterface $asset, $options = array())
  35. {
  36. return $this->assetsHelper->getUrl($asset->getTargetPath(), isset($options['package']) ? $options['package'] : null);
  37. }
  38. }