File tree 2 files changed +15
-2
lines changed
2 files changed +15
-2
lines changed Original file line number Diff line number Diff line change @@ -37,15 +37,21 @@ final class EventListener
37
37
*/
38
38
private $ lastModified ;
39
39
40
+ /**
41
+ * @var bool Symfony kernel.debug mode
42
+ */
43
+ private $ debug ;
44
+
40
45
/**
41
46
* @param Reader $reader
42
47
* @param ContainerInterface $container
43
48
*/
44
- public function __construct (Reader $ reader , ContainerInterface $ container )
49
+ public function __construct (Reader $ reader , ContainerInterface $ container, bool $ debug = false )
45
50
{
46
51
$ this ->reader = $ reader ;
47
52
$ this ->container = $ container ;
48
53
$ this ->lastModified = new \SplObjectStorage ();
54
+ $ this ->debug = $ debug ;
49
55
}
50
56
51
57
/**
@@ -72,6 +78,12 @@ public function onKernelController(FilterControllerEvent $event)
72
78
73
79
$ this ->lastModified [$ request ] = $ lastModified ;
74
80
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
+
75
87
$ response = new Response ();
76
88
$ response ->setLastModified ($ lastModified );
77
89
@@ -108,7 +120,7 @@ private function findAnnotation(callable $controllerCallable)
108
120
return null ;
109
121
}
110
122
111
- list ( $ class , $ methodName) = $ controllerCallable ;
123
+ [ $ class , $ methodName] = $ controllerCallable ;
112
124
$ method = new \ReflectionMethod ($ class , $ methodName );
113
125
114
126
/** @var ReplaceWithNotModifiedResponse|null $annotation */
Original file line number Diff line number Diff line change 7
7
<service id =" Webfactory\HttpCacheBundle\NotModified\EventListener" class =" Webfactory\HttpCacheBundle\NotModified\EventListener" public =" true" >
8
8
<argument type =" service" id =" annotation_reader" />
9
9
<argument type =" service" id =" service_container" />
10
+ <argument >%kernel.debug%</argument >
10
11
<tag name =" kernel.event_listener" event =" kernel.controller" priority =" -200" />
11
12
<tag name =" kernel.event_listener" event =" kernel.response" />
12
13
</service >
You can’t perform that action at this time.
0 commit comments