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

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