44
55use Bugsnag \BugsnagBundle \BugsnagBundle ;
66use Bugsnag \BugsnagBundle \Request \SymfonyResolver ;
7- use Bugsnag \Callbacks \CustomUser ;
87use Bugsnag \Client ;
98use 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 ;
139
1410class ClientFactory
1511{
@@ -20,20 +16,6 @@ class ClientFactory
2016 */
2117 protected $ resolver ;
2218
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-
3719 /**
3820 * The api key.
3921 *
@@ -55,13 +37,6 @@ class ClientFactory
5537 */
5638 protected $ callbacks ;
5739
58- /**
59- * User detection enabled.
60- *
61- * @var bool
62- */
63- protected $ user ;
64-
6540 /**
6641 * The type.
6742 *
@@ -150,12 +125,9 @@ class ClientFactory
150125 * Create a new client factory instance.
151126 *
152127 * @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
155128 * @param string|null $key
156129 * @param string|null $endpoint
157130 * @param bool $callbacks
158- * @param bool $user
159131 * @param string|null $type
160132 * @param string|null $version
161133 * @param bool $batch
@@ -172,12 +144,9 @@ class ClientFactory
172144 */
173145 public function __construct (
174146 SymfonyResolver $ resolver ,
175- TokenStorageInterface $ tokens = null ,
176- AuthorizationCheckerInterface $ checker = null ,
177147 $ key = null ,
178148 $ endpoint = null ,
179149 $ callbacks = true ,
180- $ user = true ,
181150 $ type = null ,
182151 $ version = true ,
183152 $ batch = null ,
@@ -191,12 +160,9 @@ public function __construct(
191160 array $ filters = null
192161 ) {
193162 $ this ->resolver = $ resolver ;
194- $ this ->tokens = $ tokens ;
195- $ this ->checker = $ checker ;
196163 $ this ->key = $ key ;
197164 $ this ->endpoint = $ endpoint ;
198165 $ this ->callbacks = $ callbacks ;
199- $ this ->user = $ user ;
200166 $ this ->type = $ type ;
201167 $ this ->version = $ version ;
202168 $ this ->batch = $ batch ;
@@ -245,10 +211,6 @@ public function make()
245211 $ client ->registerDefaultCallbacks ();
246212 }
247213
248- if ($ this ->tokens && $ this ->checker && $ this ->user ) {
249- $ this ->setupUserDetection ($ client , $ this ->tokens , $ this ->checker );
250- }
251-
252214 $ this ->setupPaths ($ client , $ this ->strip , $ this ->project , $ this ->root );
253215
254216 $ client ->setReleaseStage ($ this ->stage === 'prod ' ? 'production ' : $ this ->stage );
@@ -282,34 +244,6 @@ public function make()
282244 return $ client ;
283245 }
284246
285- /**
286- * Setup user detection.
287- *
288- * @param \Bugsnag\Client $client
289- * @param \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokens
290- * @param \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface $checker
291- *
292- * @return void
293- */
294- protected function setupUserDetection (Client $ client , TokenStorageInterface $ tokens , AuthorizationCheckerInterface $ checker )
295- {
296- $ client ->registerCallback (new CustomUser (function () use ($ tokens , $ checker ) {
297- $ token = $ tokens ->getToken ();
298-
299- if (!$ token || !$ checker ->isGranted ('IS_AUTHENTICATED_REMEMBERED ' )) {
300- return ;
301- }
302-
303- $ user = $ token ->getUser ();
304-
305- if ($ user instanceof UserInterface) {
306- return ['id ' => $ user ->getUsername ()];
307- }
308-
309- return ['id ' => (string ) $ user ];
310- }));
311- }
312-
313247 /**
314248 * Setup the client paths.
315249 *
0 commit comments