2727 */
2828class RequestDataCollector extends DataCollector implements EventSubscriberInterface
2929{
30+ /** @var \SplObjectStorage */
3031 protected $ controllers ;
3132
3233 public function __construct ()
@@ -286,26 +287,9 @@ public function getRedirect()
286287 return isset ($ this ->data ['redirect ' ]) ? $ this ->data ['redirect ' ] : false ;
287288 }
288289
289- /**
290- * Gets the parsed forward controller.
291- *
292- * @return array|bool An array with keys 'token' the forward profile token, and
293- * 'controller' the parsed forward controller, false otherwise
294- */
295- public function getForward ()
296- {
297- return isset ($ this ->data ['forward ' ]) ? $ this ->data ['forward ' ] : false ;
298- }
299-
300290 public function onKernelController (FilterControllerEvent $ event )
301291 {
302292 $ this ->controllers [$ event ->getRequest ()] = $ event ->getController ();
303-
304- if ($ parentRequestAttributes = $ event ->getRequest ()->attributes ->get ('_forwarded ' )) {
305- if ($ parentRequestAttributes instanceof ParameterBag) {
306- $ parentRequestAttributes ->set ('_forward_controller ' , $ event ->getController ());
307- }
308- }
309293 }
310294
311295 public static function getSubscribedEvents ()
@@ -321,51 +305,14 @@ public function getName()
321305 return 'request ' ;
322306 }
323307
324- private function getCookieHeader ($ name , $ value , $ expires , $ path , $ domain , $ secure , $ httponly )
325- {
326- $ cookie = sprintf ('%s=%s ' , $ name , urlencode ($ value ));
327-
328- if (0 !== $ expires ) {
329- if (is_numeric ($ expires )) {
330- $ expires = (int ) $ expires ;
331- } elseif ($ expires instanceof \DateTime) {
332- $ expires = $ expires ->getTimestamp ();
333- } else {
334- $ tmp = strtotime ($ expires );
335- if (false === $ tmp || -1 == $ tmp ) {
336- throw new \InvalidArgumentException (sprintf ('The "expires" cookie parameter is not valid (%s). ' , $ expires ));
337- }
338- $ expires = $ tmp ;
339- }
340-
341- $ cookie .= '; expires= ' .str_replace ('+0000 ' , '' , \DateTime::createFromFormat ('U ' , $ expires , new \DateTimeZone ('GMT ' ))->format ('D, d-M-Y H:i:s T ' ));
342- }
343-
344- if ($ domain ) {
345- $ cookie .= '; domain= ' .$ domain ;
346- }
347-
348- $ cookie .= '; path= ' .$ path ;
349-
350- if ($ secure ) {
351- $ cookie .= '; secure ' ;
352- }
353-
354- if ($ httponly ) {
355- $ cookie .= '; httponly ' ;
356- }
357-
358- return $ cookie ;
359- }
360-
361308 /**
362309 * Parse a controller.
363310 *
364311 * @param mixed $controller The controller to parse
365312 *
366313 * @return array|string An array of controller data or a simple string
367314 */
368- private function parseController ($ controller )
315+ protected function parseController ($ controller )
369316 {
370317 if (is_string ($ controller ) && false !== strpos ($ controller , ':: ' )) {
371318 $ controller = explode (':: ' , $ controller );
@@ -418,4 +365,41 @@ private function parseController($controller)
418365
419366 return (string ) $ controller ?: 'n/a ' ;
420367 }
368+
369+ private function getCookieHeader ($ name , $ value , $ expires , $ path , $ domain , $ secure , $ httponly )
370+ {
371+ $ cookie = sprintf ('%s=%s ' , $ name , urlencode ($ value ));
372+
373+ if (0 !== $ expires ) {
374+ if (is_numeric ($ expires )) {
375+ $ expires = (int ) $ expires ;
376+ } elseif ($ expires instanceof \DateTime) {
377+ $ expires = $ expires ->getTimestamp ();
378+ } else {
379+ $ tmp = strtotime ($ expires );
380+ if (false === $ tmp || -1 == $ tmp ) {
381+ throw new \InvalidArgumentException (sprintf ('The "expires" cookie parameter is not valid (%s). ' , $ expires ));
382+ }
383+ $ expires = $ tmp ;
384+ }
385+
386+ $ cookie .= '; expires= ' .str_replace ('+0000 ' , '' , \DateTime::createFromFormat ('U ' , $ expires , new \DateTimeZone ('GMT ' ))->format ('D, d-M-Y H:i:s T ' ));
387+ }
388+
389+ if ($ domain ) {
390+ $ cookie .= '; domain= ' .$ domain ;
391+ }
392+
393+ $ cookie .= '; path= ' .$ path ;
394+
395+ if ($ secure ) {
396+ $ cookie .= '; secure ' ;
397+ }
398+
399+ if ($ httponly ) {
400+ $ cookie .= '; httponly ' ;
401+ }
402+
403+ return $ cookie ;
404+ }
421405}
0 commit comments