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 *
@@ -149,36 +124,30 @@ class ClientFactory
149124 /**
150125 * Create a new client factory instance.
151126 *
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
171143 *
172144 * @return void
173145 */
174146 public function __construct (
175147 SymfonyResolver $ resolver ,
176- TokenStorageInterface $ tokens = null ,
177- AuthorizationCheckerInterface $ checker = null ,
178148 $ key = null ,
179149 $ endpoint = null ,
180150 $ callbacks = true ,
181- $ user = true ,
182151 $ type = null ,
183152 $ version = true ,
184153 $ batch = null ,
@@ -193,12 +162,9 @@ public function __construct(
193162 array $ filters = null
194163 ) {
195164 $ this ->resolver = $ resolver ;
196- $ this ->tokens = $ tokens ;
197- $ this ->checker = $ checker ;
198165 $ this ->key = $ key ;
199166 $ this ->endpoint = $ endpoint ;
200167 $ this ->callbacks = $ callbacks ;
201- $ this ->user = $ user ;
202168 $ this ->type = $ type ;
203169 $ this ->version = $ version ;
204170 $ this ->batch = $ batch ;
@@ -228,10 +194,6 @@ public function make()
228194 $ client ->registerDefaultCallbacks ();
229195 }
230196
231- if ($ this ->tokens && $ this ->checker && $ this ->user ) {
232- $ this ->setupUserDetection ($ client , $ this ->tokens , $ this ->checker );
233- }
234-
235197 $ this ->setupPaths ($ client , $ this ->strip , $ this ->project , $ this ->root );
236198
237199 $ client ->setReleaseStage ($ this ->stage ?: ($ this ->env === 'prod ' ? 'production ' : $ this ->env ));
@@ -261,34 +223,6 @@ public function make()
261223 return $ client ;
262224 }
263225
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-
292226 /**
293227 * Setup the client paths.
294228 *
0 commit comments