vendor/symfony/twig-bridge/Extension/HttpKernelRuntime.php line 48

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.  * @final since Symfony 4.4
  19.  */
  20. class HttpKernelRuntime
  21. {
  22.     private $handler;
  23.     public function __construct(FragmentHandler $handler)
  24.     {
  25.         $this->handler $handler;
  26.     }
  27.     /**
  28.      * Renders a fragment.
  29.      *
  30.      * @param string|ControllerReference $uri     A URI as a string or a ControllerReference instance
  31.      * @param array                      $options An array of options
  32.      *
  33.      * @return string The fragment content
  34.      *
  35.      * @see FragmentHandler::render()
  36.      */
  37.     public function renderFragment($uri$options = [])
  38.     {
  39.         $strategy = isset($options['strategy']) ? $options['strategy'] : 'inline';
  40.         unset($options['strategy']);
  41.         return $this->handler->render($uri$strategy$options);
  42.     }
  43.     /**
  44.      * Renders a fragment.
  45.      *
  46.      * @param string                     $strategy A strategy name
  47.      * @param string|ControllerReference $uri      A URI as a string or a ControllerReference instance
  48.      * @param array                      $options  An array of options
  49.      *
  50.      * @return string The fragment content
  51.      *
  52.      * @see FragmentHandler::render()
  53.      */
  54.     public function renderFragmentStrategy($strategy$uri$options = [])
  55.     {
  56.         return $this->handler->render($uri$strategy$options);
  57.     }
  58. }