AssetsHelper.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Templating\Helper;
  11. use Symfony\Component\Templating\Asset\PathPackage;
  12. use Symfony\Component\Templating\Asset\UrlPackage;
  13. /**
  14. * AssetsHelper helps manage asset URLs.
  15. *
  16. * Usage:
  17. *
  18. * <code>
  19. * <img src="<?php echo $view['assets']->getUrl('foo.png') ?>" />
  20. * </code>
  21. *
  22. * @author Fabien Potencier <fabien@symfony.com>
  23. * @author Kris Wallsmith <kris@symfony.com>
  24. */
  25. class AssetsHelper extends CoreAssetsHelper
  26. {
  27. /**
  28. * Constructor.
  29. *
  30. * @param string $basePath The base path
  31. * @param string|array $baseUrls Base asset URLs
  32. * @param string $version The asset version
  33. * @param string $format The version format
  34. * @param array $namedPackages Additional packages
  35. */
  36. public function __construct($basePath = null, $baseUrls = array(), $version = null, $format = null, $namedPackages = array())
  37. {
  38. if ($baseUrls) {
  39. $defaultPackage = new UrlPackage($baseUrls, $version, $format);
  40. } else {
  41. $defaultPackage = new PathPackage($basePath, $version, $format);
  42. }
  43. parent::__construct($defaultPackage, $namedPackages);
  44. }
  45. }