vendor/symfony/symfony/src/Symfony/Bridge/Twig/Extension/HttpKernelRuntime.php line 46

Open in your IDE?
  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\Bridge\Twig\Extension;
  11. use Symfony\Component\HttpKernel\Controller\ControllerReference;
  12. use Symfony\Component\HttpKernel\Fragment\FragmentHandler;
  13. /**
  14.  * Provides integration with the HttpKernel component.
  15.  *
  16.  * @author Fabien Potencier <fabien@symfony.com>
  17.  */
  18. class HttpKernelRuntime
  19. {
  20.     private $handler;
  21.     public function __construct(FragmentHandler $handler)
  22.     {
  23.         $this->handler $handler;
  24.     }
  25.     /**
  26.      * Renders a fragment.
  27.      *
  28.      * @param string|ControllerReference $uri     A URI as a string or a ControllerReference instance
  29.      * @param array                      $options An array of options
  30.      *
  31.      * @return string The fragment content
  32.      *
  33.      * @see FragmentHandler::render()
  34.      */
  35.     public function renderFragment($uri$options = [])
  36.     {
  37.         $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
  38.         unset($options['strategy']);
  39.         return $this->handler->render($uri$strategy$options);
  40.     }
  41.     /**
  42.      * Renders a fragment.
  43.      *
  44.      * @param string                     $strategy A strategy name
  45.      * @param string|ControllerReference $uri      A URI as a string or a ControllerReference instance
  46.      * @param array                      $options  An array of options
  47.      *
  48.      * @return string The fragment content
  49.      *
  50.      * @see FragmentHandler::render()
  51.      */
  52.     public function renderFragmentStrategy($strategy$uri$options = [])
  53.     {
  54.         return $this->handler->render($uri$strategy$options);
  55.     }
  56. }