*/ class Esi extends AbstractSmartyPlugin { /** @var EsiFragmentRenderer */ protected $esiFragmentRender; /** @var RequestStack */ protected $requestStack; public function __construct(EsiFragmentRenderer $esiFragmentRenderer, RequestStack $requestStack) { $this->esiFragmentRender = $esiFragmentRenderer; $this->requestStack = $requestStack; } public function renderEsi($params, $template = null) { $path = $this->getParam($params, 'path'); $alt = $this->getParam($params, 'alt'); $ignore_errors = $this->getParam($params, 'ignore_errors'); $comment = $this->getParam($params, 'comment'); if (null === $path) { return; } $response = $this->esiFragmentRender->render($path, $this->requestStack->getCurrentRequest(), array( 'alt' => $alt, 'ignore_errors' => $ignore_errors, 'comment' => $comment )); if (!$response->isSuccessful()) { return null; } return $response->getContent(); } /** * @return array an array of SmartyPluginDescriptor */ public function getPluginDescriptors() { return array( new SmartyPluginDescriptor('function', 'render_esi', $this, 'renderEsi') ); } }