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

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.     private Environment $twig;
  20.     public function __construct(Environment $twig)
  21.     {
  22.         $this->twig $twig;
  23.     }
  24.     public function render(TemplateBlock $templateBlock, array $context = []): string
  25.     {
  26.         return $this->twig->render(
  27.             $templateBlock->getTemplate(),
  28.             array_replace($templateBlock->getContext(), $context)
  29.         );
  30.     }
  31. }