vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/Renderer/DelegatingTemplateEventRenderer.php line 27

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\TemplateBlockRegistryInterface;
  13. /**
  14.  * @experimental
  15.  */
  16. final class DelegatingTemplateEventRenderer implements TemplateEventRendererInterface
  17. {
  18.     public function __construct(private TemplateBlockRegistryInterface $templateBlockRegistry, private TemplateBlockRendererInterface $templateBlockRenderer)
  19.     {
  20.     }
  21.     public function render(array $eventNames, array $context = []): string
  22.     {
  23.         $templateBlocks $this->templateBlockRegistry->findEnabledForEvents($eventNames);
  24.         $renderedTemplates = [];
  25.         foreach ($templateBlocks as $templateBlock) {
  26.             $renderedTemplates[] = $this->templateBlockRenderer->render($templateBlock$context);
  27.         }
  28.         return implode("\n"$renderedTemplates);
  29.     }
  30. }