15
15
use FOS \HttpCacheBundle \Configuration \Tag ;
16
16
use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
17
17
use Symfony \Component \HttpFoundation \Request ;
18
- use Symfony \Component \HttpFoundation \Response ;
19
18
use Symfony \Component \HttpKernel \Event \FilterResponseEvent ;
20
19
use Symfony \Component \HttpKernel \KernelEvents ;
21
20
use Symfony \Component \ExpressionLanguage \ExpressionLanguage ;
@@ -78,10 +77,7 @@ public function onKernelResponse(FilterResponseEvent $event)
78
77
$ tags [] = $ tag ;
79
78
}
80
79
foreach ($ configuredTags ['expressions ' ] as $ expression ) {
81
- $ tags [] = $ this ->expressionLanguage ->evaluate ($ expression , array (
82
- 'request ' => $ request ,
83
- 'response ' => $ response ,
84
- ));
80
+ $ tags [] = $ this ->evaluateTag ($ expression , $ request );
85
81
}
86
82
}
87
83
@@ -98,6 +94,16 @@ public function onKernelResponse(FilterResponseEvent $event)
98
94
}
99
95
}
100
96
97
+ /**
98
+ * {@inheritdoc}
99
+ */
100
+ public static function getSubscribedEvents ()
101
+ {
102
+ return array (
103
+ KernelEvents::RESPONSE => 'onKernelResponse '
104
+ );
105
+ }
106
+
101
107
/**
102
108
* Get the tags from the annotations on the controller that was used in the
103
109
* request.
@@ -118,9 +124,9 @@ private function getAnnotationTags(Request $request)
118
124
$ tags = array ();
119
125
foreach ($ tagConfigurations as $ tagConfiguration ) {
120
126
if (null !== $ tagConfiguration ->getExpression ()) {
121
- $ tags [] = $ this ->expressionLanguage -> evaluate (
127
+ $ tags [] = $ this ->evaluateTag (
122
128
$ tagConfiguration ->getExpression (),
123
- $ request-> attributes -> all ()
129
+ $ request
124
130
);
125
131
} else {
126
132
$ tags = array_merge ($ tags , $ tagConfiguration ->getTags ());
@@ -131,12 +137,19 @@ private function getAnnotationTags(Request $request)
131
137
}
132
138
133
139
/**
134
- * {@inheritdoc}
140
+ * Evaluate a tag that contains expressions
141
+ *
142
+ * @param string $expression
143
+ * @param Request $request
144
+ *
145
+ * @return string Evaluaated tag
135
146
*/
136
- public static function getSubscribedEvents ( )
147
+ private function evaluateTag ( $ expression , Request $ request )
137
148
{
138
- return array (
139
- KernelEvents::RESPONSE => 'onKernelResponse '
149
+ return $ this ->expressionLanguage ->evaluate (
150
+ $ expression ,
151
+ $ request ->attributes ->all ()
140
152
);
141
153
}
154
+
142
155
}
0 commit comments