1515use FOS \HttpCacheBundle \Configuration \Tag ;
1616use Symfony \Component \EventDispatcher \EventSubscriberInterface ;
1717use Symfony \Component \HttpFoundation \Request ;
18- use Symfony \Component \HttpFoundation \Response ;
1918use Symfony \Component \HttpKernel \Event \FilterResponseEvent ;
2019use Symfony \Component \HttpKernel \KernelEvents ;
2120use Symfony \Component \ExpressionLanguage \ExpressionLanguage ;
@@ -78,10 +77,7 @@ public function onKernelResponse(FilterResponseEvent $event)
7877 $ tags [] = $ tag ;
7978 }
8079 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 );
8581 }
8682 }
8783
@@ -98,6 +94,16 @@ public function onKernelResponse(FilterResponseEvent $event)
9894 }
9995 }
10096
97+ /**
98+ * {@inheritdoc}
99+ */
100+ public static function getSubscribedEvents ()
101+ {
102+ return array (
103+ KernelEvents::RESPONSE => 'onKernelResponse '
104+ );
105+ }
106+
101107 /**
102108 * Get the tags from the annotations on the controller that was used in the
103109 * request.
@@ -118,9 +124,9 @@ private function getAnnotationTags(Request $request)
118124 $ tags = array ();
119125 foreach ($ tagConfigurations as $ tagConfiguration ) {
120126 if (null !== $ tagConfiguration ->getExpression ()) {
121- $ tags [] = $ this ->expressionLanguage -> evaluate (
127+ $ tags [] = $ this ->evaluateTag (
122128 $ tagConfiguration ->getExpression (),
123- $ request-> attributes -> all ()
129+ $ request
124130 );
125131 } else {
126132 $ tags = array_merge ($ tags , $ tagConfiguration ->getTags ());
@@ -131,12 +137,19 @@ private function getAnnotationTags(Request $request)
131137 }
132138
133139 /**
134- * {@inheritdoc}
140+ * Evaluate a tag that contains expressions
141+ *
142+ * @param string $expression
143+ * @param Request $request
144+ *
145+ * @return string Evaluaated tag
135146 */
136- public static function getSubscribedEvents ( )
147+ private function evaluateTag ( $ expression , Request $ request )
137148 {
138- return array (
139- KernelEvents::RESPONSE => 'onKernelResponse '
149+ return $ this ->expressionLanguage ->evaluate (
150+ $ expression ,
151+ $ request ->attributes ->all ()
140152 );
141153 }
154+
142155}
0 commit comments