PackageFactory.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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\Bundle\FrameworkBundle\Templating\Asset;
  11. @trigger_error('The Symfony\Bundle\FrameworkBundle\Templating\Asset\PackageFactory is deprecated since Symfony 2.7 and will be removed in 3.0. Use the Asset component instead.', E_USER_DEPRECATED);
  12. use Symfony\Component\DependencyInjection\ContainerInterface;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\Templating\Asset\PackageInterface;
  15. /**
  16. * Creates packages based on whether the current request is secure.
  17. *
  18. * @author Kris Wallsmith <kris@symfony.com>
  19. *
  20. * @deprecated since 2.7, will be removed in 3.0. Use the Asset component instead.
  21. */
  22. class PackageFactory
  23. {
  24. private $container;
  25. public function __construct(ContainerInterface $container)
  26. {
  27. $this->container = $container;
  28. }
  29. /**
  30. * Returns either the HTTP or SSL version of an asset package.
  31. *
  32. * @param Request $request The current request
  33. * @param string $httpId The id for the package to use when the current request is HTTP
  34. * @param string $sslId The id for the package to use when the current request is SSL
  35. *
  36. * @return PackageInterface The package
  37. */
  38. public function getPackage(Request $request, $httpId, $sslId)
  39. {
  40. return $this->container->get($request->isSecure() ? $sslId : $httpId);
  41. }
  42. }