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

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.     /** @var TemplateBlockRegistryInterface */
  19.     private $templateBlockRegistry;
  20.     /** @var TemplateBlockRendererInterface */
  21.     private $templateBlockRenderer;
  22.     public function __construct(TemplateBlockRegistryInterface $templateBlockRegistryTemplateBlockRendererInterface $templateBlockRenderer)
  23.     {
  24.         $this->templateBlockRegistry $templateBlockRegistry;
  25.         $this->templateBlockRenderer $templateBlockRenderer;
  26.     }
  27.     public function render(array $eventNames, array $context = []): string
  28.     {
  29.         $templateBlocks $this->templateBlockRegistry->findEnabledForEvents($eventNames);
  30.         $renderedTemplates = [];
  31.         foreach ($templateBlocks as $templateBlock) {
  32.             $renderedTemplates[] = $this->templateBlockRenderer->render($templateBlock$context);
  33.         }
  34.         return implode("\n"$renderedTemplates);
  35.     }
  36. }