4
4
5
5
use Bugsnag \BugsnagBundle \BugsnagBundle ;
6
6
use Bugsnag \BugsnagBundle \Request \SymfonyResolver ;
7
- use Bugsnag \Callbacks \CustomUser ;
8
7
use Bugsnag \Client ;
9
8
use Bugsnag \Configuration as Config ;
10
- use Symfony \Component \Security \Core \Authentication \Token \Storage \TokenStorageInterface ;
11
- use Symfony \Component \Security \Core \Authorization \AuthorizationCheckerInterface ;
12
- use Symfony \Component \Security \Core \User \UserInterface ;
13
9
14
10
class ClientFactory
15
11
{
@@ -20,20 +16,6 @@ class ClientFactory
20
16
*/
21
17
protected $ resolver ;
22
18
23
- /**
24
- * The token resolver.
25
- *
26
- * @var \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface|null
27
- */
28
- protected $ tokens ;
29
-
30
- /**
31
- * The auth checker.
32
- *
33
- * @var \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface|null
34
- */
35
- protected $ checker ;
36
-
37
19
/**
38
20
* The api key.
39
21
*
@@ -55,13 +37,6 @@ class ClientFactory
55
37
*/
56
38
protected $ callbacks ;
57
39
58
- /**
59
- * User detection enabled.
60
- *
61
- * @var bool
62
- */
63
- protected $ user ;
64
-
65
40
/**
66
41
* The type.
67
42
*
@@ -149,36 +124,30 @@ class ClientFactory
149
124
/**
150
125
* Create a new client factory instance.
151
126
*
152
- * @param \Bugsnag\BugsnagBundle\Request\SymfonyResolver $resolver
153
- * @param \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface|null $tokens
154
- * @param \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface|null $checker
155
- * @param string|null $key
156
- * @param string|null $endpoint
157
- * @param bool $callbacks
158
- * @param bool $user
159
- * @param string|null $type
160
- * @param string|null $version
161
- * @param bool $batch
162
- * @param string|null $hostname
163
- * @param bool $code
164
- * @param string|null $strip
165
- * @param string|null $project
166
- * @param string|null $root
167
- * @param string|null $env
168
- * @param string|null $stage
169
- * @param string[]|null $stages
170
- * @param string[]|null $filters
127
+ * @param \Bugsnag\BugsnagBundle\Request\SymfonyResolver $resolver
128
+ * @param string|null $key
129
+ * @param string|null $endpoint
130
+ * @param bool $callbacks
131
+ * @param string|null $type
132
+ * @param string|null $version
133
+ * @param bool $batch
134
+ * @param string|null $hostname
135
+ * @param bool $code
136
+ * @param string|null $strip
137
+ * @param string|null $project
138
+ * @param string|null $root
139
+ * @param string|null $env
140
+ * @param string|null $stage
141
+ * @param string[]|null $stages
142
+ * @param string[]|null $filters
171
143
*
172
144
* @return void
173
145
*/
174
146
public function __construct (
175
147
SymfonyResolver $ resolver ,
176
- TokenStorageInterface $ tokens = null ,
177
- AuthorizationCheckerInterface $ checker = null ,
178
148
$ key = null ,
179
149
$ endpoint = null ,
180
150
$ callbacks = true ,
181
- $ user = true ,
182
151
$ type = null ,
183
152
$ version = true ,
184
153
$ batch = null ,
@@ -193,12 +162,9 @@ public function __construct(
193
162
array $ filters = null
194
163
) {
195
164
$ this ->resolver = $ resolver ;
196
- $ this ->tokens = $ tokens ;
197
- $ this ->checker = $ checker ;
198
165
$ this ->key = $ key ;
199
166
$ this ->endpoint = $ endpoint ;
200
167
$ this ->callbacks = $ callbacks ;
201
- $ this ->user = $ user ;
202
168
$ this ->type = $ type ;
203
169
$ this ->version = $ version ;
204
170
$ this ->batch = $ batch ;
@@ -228,10 +194,6 @@ public function make()
228
194
$ client ->registerDefaultCallbacks ();
229
195
}
230
196
231
- if ($ this ->tokens && $ this ->checker && $ this ->user ) {
232
- $ this ->setupUserDetection ($ client , $ this ->tokens , $ this ->checker );
233
- }
234
-
235
197
$ this ->setupPaths ($ client , $ this ->strip , $ this ->project , $ this ->root );
236
198
237
199
$ client ->setReleaseStage ($ this ->stage ?: ($ this ->env === 'prod ' ? 'production ' : $ this ->env ));
@@ -261,34 +223,6 @@ public function make()
261
223
return $ client ;
262
224
}
263
225
264
- /**
265
- * Setup user detection.
266
- *
267
- * @param \Bugsnag\Client $client
268
- * @param \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokens
269
- * @param \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface $checker
270
- *
271
- * @return void
272
- */
273
- protected function setupUserDetection (Client $ client , TokenStorageInterface $ tokens , AuthorizationCheckerInterface $ checker )
274
- {
275
- $ client ->registerCallback (new CustomUser (function () use ($ tokens , $ checker ) {
276
- $ token = $ tokens ->getToken ();
277
-
278
- if (!$ token || !$ checker ->isGranted ('IS_AUTHENTICATED_REMEMBERED ' )) {
279
- return ;
280
- }
281
-
282
- $ user = $ token ->getUser ();
283
-
284
- if ($ user instanceof UserInterface) {
285
- return ['id ' => $ user ->getUsername ()];
286
- }
287
-
288
- return ['id ' => (string ) $ user ];
289
- }));
290
- }
291
-
292
226
/**
293
227
* Setup the client paths.
294
228
*
0 commit comments