ContainerAwareHIncludeFragmentRenderer.php 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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\Fragment;
  11. @trigger_error('The '.__NAMESPACE__.'\ContainerAwareHIncludeFragmentRenderer class is deprecated since Symfony 2.7 and will be removed in 3.0. Use Symfony\Bundle\FrameworkBundle\Fragment\HIncludeFragmentRenderer instead.', E_USER_DEPRECATED);
  12. use Symfony\Component\DependencyInjection\ContainerInterface;
  13. use Symfony\Component\HttpFoundation\Request;
  14. use Symfony\Component\HttpKernel\Fragment\HIncludeFragmentRenderer;
  15. use Symfony\Component\HttpKernel\UriSigner;
  16. /**
  17. * Implements the Hinclude rendering strategy.
  18. *
  19. * @author Fabien Potencier <fabien@symfony.com>
  20. *
  21. * @deprecated since version 2.7, to be removed in 3.0. Use Symfony\Bundle\FrameworkBundle\Fragment\HIncludeFragmentRenderer instead.
  22. */
  23. class ContainerAwareHIncludeFragmentRenderer extends HIncludeFragmentRenderer
  24. {
  25. private $container;
  26. /**
  27. * {@inheritdoc}
  28. */
  29. public function __construct(ContainerInterface $container, UriSigner $signer = null, $globalDefaultTemplate = null)
  30. {
  31. $this->container = $container;
  32. parent::__construct(null, $signer, $globalDefaultTemplate, $container->getParameter('kernel.charset'));
  33. }
  34. /**
  35. * {@inheritdoc}
  36. */
  37. public function render($uri, Request $request, array $options = array())
  38. {
  39. // setting the templating cannot be done in the constructor
  40. // as it would lead to an infinite recursion in the service container
  41. if (!$this->hasTemplating()) {
  42. $this->setTemplating($this->container->get('templating'));
  43. }
  44. return parent::render($uri, $request, $options);
  45. }
  46. }