vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/Renderer/TwigTemplateBlockRenderer.php line 36

Open in your IDE?
  1. <?php
  2. /*
  3.  * This file is part of the Sylius package.
  4.  *
  5.  * (c) Paweł Jędrzejewski
  6.  *
  7.  * For the full copyright and license information, please view the LICENSE
  8.  * file that was distributed with this source code.
  9.  */
  10. declare(strict_types=1);
  11. namespace Sylius\Bundle\UiBundle\Renderer;
  12. use Sylius\Bundle\UiBundle\Registry\TemplateBlock;
  13. use Twig\Environment;
  14. /**
  15.  * @experimental
  16.  */
  17. final class TwigTemplateBlockRenderer implements TemplateBlockRendererInterface
  18. {
  19.     /** @var Environment */
  20.     private $twig;
  21.     public function __construct(Environment $twig)
  22.     {
  23.         $this->twig $twig;
  24.     }
  25.     public function render(TemplateBlock $templateBlock, array $context = []): string
  26.     {
  27.         return $this->twig->render(
  28.             $templateBlock->getTemplate(),
  29.             array_replace($templateBlock->getContext(), $context)
  30.         );
  31.     }
  32. }