27
27
*/
28
28
class RequestDataCollector extends DataCollector implements EventSubscriberInterface
29
29
{
30
+ /** @var \SplObjectStorage */
30
31
protected $ controllers ;
31
32
32
33
public function __construct ()
@@ -286,26 +287,9 @@ public function getRedirect()
286
287
return isset ($ this ->data ['redirect ' ]) ? $ this ->data ['redirect ' ] : false ;
287
288
}
288
289
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
-
300
290
public function onKernelController (FilterControllerEvent $ event )
301
291
{
302
292
$ 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
- }
309
293
}
310
294
311
295
public static function getSubscribedEvents ()
@@ -321,51 +305,14 @@ public function getName()
321
305
return 'request ' ;
322
306
}
323
307
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
-
361
308
/**
362
309
* Parse a controller.
363
310
*
364
311
* @param mixed $controller The controller to parse
365
312
*
366
313
* @return array|string An array of controller data or a simple string
367
314
*/
368
- private function parseController ($ controller )
315
+ protected function parseController ($ controller )
369
316
{
370
317
if (is_string ($ controller ) && false !== strpos ($ controller , ':: ' )) {
371
318
$ controller = explode (':: ' , $ controller );
@@ -418,4 +365,41 @@ private function parseController($controller)
418
365
419
366
return (string ) $ controller ?: 'n/a ' ;
420
367
}
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
+ }
421
405
}
0 commit comments