I understand that this question is very old, and since then, you probably found a solution, however, I recently encountered the same problem, and around it the FragmentListener class was replaced with my own and set the attribute to the Request object. Thanks @Johnny for the tip to the FragmentListener .
Something like the following:
php class:
<?php namespace Your\Namespace\Here; use Symfony\Component\HttpKernel\Event\GetResponseEvent; use Symfony\Component\HttpKernel\EventListener\FragmentListener as SymfonyFragmentListener; class FragmentListener extends SymfonyFragmentListener { private $signer; private $fragmentPath; public function __construct(UriSigner $signer, $fragmentPath = '/_fragment') { parent::__construct($signer, $fragmentPath); $this->signer = $signer; $this->fragmentPath = $fragmentPath; } public function onKernelRequest(GetResponseEvent $event) { $request = $event->getRequest(); if ( $request->attributes->has('_controller') || $this->fragmentPath !== rawurldecode($request->getPathInfo()) ) { return; } $event->getRequest()->attributes->set('esi', true); parent::onKernelRequest($event); } }
service definition:
<?xml version="1.0" ?> <container xmlns="http://symfony.com/schema/dic/services" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd" > <parameters> <parameter key="fragment.listener.class">Your\Namespace\Here\FragmentListener</parameter> </parameters> </container>
source share