/** * {@inheritdoc} */ public function display(array $context, array $blocks = array()) { $templateContext = clone $this->template->getContext(); if ($context) { $templateContext->replace($context); } if ($this->eventDispatcher !== null) { $this->eventDispatcher->dispatch('template.rendering: ' . $this->template->getName(), new TemplateEvent($this->template, $templateContext)); } parent::display($templateContext->toArray(), $blocks); }
/** * @param Template $template * @param TemplateContext $context */ public function __construct(Template $template, TemplateContext $context = null) { $this->template = $template; $this->context = $context ?: $template->getContext(); }