vendor/sylius/sylius/src/Sylius/Bundle/UiBundle/DataCollector/TraceableTemplateBlockRenderer.php line 37

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\DataCollector;
  12. use Sylius\Bundle\UiBundle\Registry\TemplateBlock;
  13. use Sylius\Bundle\UiBundle\Renderer\TemplateBlockRendererInterface;
  14. /**
  15.  * @internal
  16.  * @experimental
  17.  */
  18. final class TraceableTemplateBlockRenderer implements TemplateBlockRendererInterface
  19. {
  20.     /** @var TemplateBlockRendererInterface */
  21.     private $templateBlockRenderer;
  22.     /** @var TemplateBlockRenderingHistory */
  23.     private $templateBlockRenderingHistory;
  24.     public function __construct(TemplateBlockRendererInterface $templateBlockRendererTemplateBlockRenderingHistory $templateBlockRenderingHistory)
  25.     {
  26.         $this->templateBlockRenderer $templateBlockRenderer;
  27.         $this->templateBlockRenderingHistory $templateBlockRenderingHistory;
  28.     }
  29.     public function render(TemplateBlock $templateBlock, array $context = []): string
  30.     {
  31.         $this->templateBlockRenderingHistory->startRenderingBlock($templateBlock$context);
  32.         $renderedBlock $this->templateBlockRenderer->render($templateBlock$context);
  33.         $this->templateBlockRenderingHistory->stopRenderingBlock($templateBlock$context);
  34.         return $renderedBlock;
  35.     }
  36. }