6
6
use DebugBar \DataCollector \Renderable ;
7
7
use DebugBar \DataCollector \DataCollector ;
8
8
use Symfony \Component \HttpFoundation \Response ;
9
+ use Illuminate \Auth \AuthManager ;
10
+ use Illuminate \Support \Contracts \ArrayableInterface ;
9
11
10
12
/**
11
13
*
@@ -29,15 +31,16 @@ class SymfonyRequestCollector extends DataCollector implements DataCollectorInte
29
31
* @param \Symfony\Component\HttpFoundation\Request $request
30
32
* @param \Symfony\Component\HttpFoundation\Request $response
31
33
* @param \Symfony\Component\HttpFoundation\Session\SessionInterface $session
34
+ * @param \Illuminate\Auth\AuthManager $auth
32
35
*/
33
- public function __construct ($ request , $ response , $ session )
36
+ public function __construct ($ request , $ response , $ session, AuthManager $ auth = null )
34
37
{
35
38
$ this ->request = $ request ;
36
39
$ this ->response = $ response ;
37
40
$ this ->session = $ session ;
41
+ $ this ->auth = $ auth ;
38
42
}
39
43
40
-
41
44
/**
42
45
* {@inheritDoc}
43
46
*/
@@ -65,6 +68,16 @@ public function getWidgets()
65
68
*/
66
69
public function collect ()
67
70
{
71
+ $ user = null ;
72
+ if ($ this ->auth ){
73
+ $ user = $ this ->auth ->user ();
74
+ if (is_null ($ user )){
75
+ $ user = 'Guest ' ;
76
+ }elseif ($ user instanceof ArrayableInterface){
77
+ $ user = $ user ->toArray ();
78
+ }
79
+ }
80
+
68
81
$ request = $ this ->request ;
69
82
$ response = $ this ->response ;
70
83
@@ -85,6 +98,7 @@ public function collect()
85
98
$ statusCode = $ response ->getStatusCode ();
86
99
87
100
$ data = array (
101
+ 'auth ' => $ user ?: '? ' ,
88
102
'format ' => $ request ->getRequestFormat (),
89
103
'content_type ' => $ response ->headers ->get ('Content-Type ' ) ? $ response ->headers ->get ('Content-Type ' ) : 'text/html ' ,
90
104
'status_text ' => isset (Response::$ statusTexts [$ statusCode ]) ? Response::$ statusTexts [$ statusCode ] : '' ,
0 commit comments