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 *
@@ -142,35 +117,29 @@ class ClientFactory
142117 /**
143118 * Create a new client factory instance.
144119 *
145- * @param \Bugsnag\BugsnagBundle\Request\SymfonyResolver $resolver
146- * @param \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface|null $tokens
147- * @param \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface|null $checker
148- * @param string|null $key
149- * @param string|null $endpoint
150- * @param bool $callbacks
151- * @param bool $user
152- * @param string|null $type
153- * @param string|null $version
154- * @param bool $batch
155- * @param string|null $hostname
156- * @param bool $code
157- * @param string|null $strip
158- * @param string|null $project
159- * @param string|null $root
160- * @param string|null $stage
161- * @param string[]|null $stages
162- * @param string[]|null $filters
120+ * @param \Bugsnag\BugsnagBundle\Request\SymfonyResolver $resolver
121+ * @param string|null $key
122+ * @param string|null $endpoint
123+ * @param bool $callbacks
124+ * @param string|null $type
125+ * @param string|null $version
126+ * @param bool $batch
127+ * @param string|null $hostname
128+ * @param bool $code
129+ * @param string|null $strip
130+ * @param string|null $project
131+ * @param string|null $root
132+ * @param string|null $stage
133+ * @param string[]|null $stages
134+ * @param string[]|null $filters
163135 *
164136 * @return void
165137 */
166138 public function __construct (
167139 SymfonyResolver $ resolver ,
168- TokenStorageInterface $ tokens = null ,
169- AuthorizationCheckerInterface $ checker = null ,
170140 $ key = null ,
171141 $ endpoint = null ,
172142 $ callbacks = true ,
173- $ user = true ,
174143 $ type = null ,
175144 $ version = true ,
176145 $ batch = null ,
@@ -184,12 +153,9 @@ public function __construct(
184153 array $ filters = null
185154 ) {
186155 $ this ->resolver = $ resolver ;
187- $ this ->tokens = $ tokens ;
188- $ this ->checker = $ checker ;
189156 $ this ->key = $ key ;
190157 $ this ->endpoint = $ endpoint ;
191158 $ this ->callbacks = $ callbacks ;
192- $ this ->user = $ user ;
193159 $ this ->type = $ type ;
194160 $ this ->version = $ version ;
195161 $ this ->batch = $ batch ;
@@ -218,10 +184,6 @@ public function make()
218184 $ client ->registerDefaultCallbacks ();
219185 }
220186
221- if ($ this ->tokens && $ this ->checker && $ this ->user ) {
222- $ this ->setupUserDetection ($ client , $ this ->tokens , $ this ->checker );
223- }
224-
225187 $ this ->setupPaths ($ client , $ this ->strip , $ this ->project , $ this ->root );
226188
227189 $ client ->setReleaseStage ($ this ->stage === 'prod ' ? 'production ' : $ this ->stage );
@@ -251,34 +213,6 @@ public function make()
251213 return $ client ;
252214 }
253215
254- /**
255- * Setup user detection.
256- *
257- * @param \Bugsnag\Client $client
258- * @param \Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface $tokens
259- * @param \Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface $checker
260- *
261- * @return void
262- */
263- protected function setupUserDetection (Client $ client , TokenStorageInterface $ tokens , AuthorizationCheckerInterface $ checker )
264- {
265- $ client ->registerCallback (new CustomUser (function () use ($ tokens , $ checker ) {
266- $ token = $ tokens ->getToken ();
267-
268- if (!$ token || !$ checker ->isGranted ('IS_AUTHENTICATED_REMEMBERED ' )) {
269- return ;
270- }
271-
272- $ user = $ token ->getUser ();
273-
274- if ($ user instanceof UserInterface) {
275- return ['id ' => $ user ->getUsername ()];
276- }
277-
278- return ['id ' => (string ) $ user ];
279- }));
280- }
281-
282216 /**
283217 * Setup the client paths.
284218 *
0 commit comments