StaticAsseticHelper.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\Component\Templating\Helper\CoreAssetsHelper;
  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 CoreAssetsHelper $assetsHelper The assets helper
  26. * @param AssetFactory $factory The asset factory
  27. */
  28. public function __construct(CoreAssetsHelper $assetsHelper, AssetFactory $factory)
  29. {
  30. $this->assetsHelper = $assetsHelper;
  31. parent::__construct($factory);
  32. }
  33. protected function getAssetUrl(AssetInterface $asset, $options = array())
  34. {
  35. return $this->assetsHelper->getUrl($asset->getTargetPath(), isset($options['package']) ? $options['package'] : null);
  36. }
  37. }