File tree Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Expand file tree Collapse file tree 2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -37,15 +37,21 @@ final class EventListener
3737 */
3838 private $ lastModified ;
3939
40+ /**
41+ * @var bool Symfony kernel.debug mode
42+ */
43+ private $ debug ;
44+
4045 /**
4146 * @param Reader $reader
4247 * @param ContainerInterface $container
4348 */
44- public function __construct (Reader $ reader , ContainerInterface $ container )
49+ public function __construct (Reader $ reader , ContainerInterface $ container, bool $ debug = false )
4550 {
4651 $ this ->reader = $ reader ;
4752 $ this ->container = $ container ;
4853 $ this ->lastModified = new \SplObjectStorage ();
54+ $ this ->debug = $ debug ;
4955 }
5056
5157 /**
@@ -72,6 +78,12 @@ public function onKernelController(FilterControllerEvent $event)
7278
7379 $ this ->lastModified [$ request ] = $ lastModified ;
7480
81+ /* Never send 304s for kernel.debug = true: This leads to confusing
82+ behavior, for example if you don't see updates to Twig templates. */
83+ if ($ this ->debug ) {
84+ return ;
85+ }
86+
7587 $ response = new Response ();
7688 $ response ->setLastModified ($ lastModified );
7789
@@ -108,7 +120,7 @@ private function findAnnotation(callable $controllerCallable)
108120 return null ;
109121 }
110122
111- list ( $ class , $ methodName) = $ controllerCallable ;
123+ [ $ class , $ methodName] = $ controllerCallable ;
112124 $ method = new \ReflectionMethod ($ class , $ methodName );
113125
114126 /** @var ReplaceWithNotModifiedResponse|null $annotation */
Original file line number Diff line number Diff line change 77 <service id =" Webfactory\HttpCacheBundle\NotModified\EventListener" class =" Webfactory\HttpCacheBundle\NotModified\EventListener" public =" true" >
88 <argument type =" service" id =" annotation_reader" />
99 <argument type =" service" id =" service_container" />
10+ <argument >%kernel.debug%</argument >
1011 <tag name =" kernel.event_listener" event =" kernel.controller" priority =" -200" />
1112 <tag name =" kernel.event_listener" event =" kernel.response" />
1213 </service >
You can’t perform that action at this time.
0 commit comments