protected function setupUserDetection(Client $client, Application $app)
    {
        try {
            $tokens = $app['security.token_storage'];
            $checker = $app['security.authorization_checker'];
        } catch (InvalidArgumentException $e) {
            return;
        }

        $client->registerCallback(new CustomUser(function () use ($tokens, $checker) {
            $token = $tokens->getToken();

            if (!$token || !$checker->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
                return;
            }

            $user = $token->getUser();

            if ($user instanceof UserInterface) {
                return ['id' => $user->getUsername()];
            }

            return ['id' => (string) $user];
        }));
    }
protected function setupUserDetection(Client $client, Application $app)
    {
        try {
            $tokens = $app['security.token_storage'];
            $checker = $app['security.authorization_checker'];
        } catch (InvalidArgumentException $e) {
            return;
        }

        $client->registerCallback(new CustomUser(function () use ($tokens, $checker) {
            $token = $tokens->getToken();

            if (!$token || !$checker->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
                return;
            }

            $user = $token->getUser();

            if ($user instanceof UserInterface) {
                return ['id' => $user->getUsername()];
            }

            return ['id' => (string) $user];
        }));
    }
protected function setupUserDetection ( Client $ client , Application $ app ) { try { $ tokens = $ app [ 'security.token_storage' ] ; $ checker = $ app [ 'security.authorization_checker' ] ; } catch ( InvalidArgumentException $ e ) { return ; } $ client -> registerCallback ( new CustomUser ( function ( ) use ( $ tokens , $ checker ) { $ token = $ tokens -> getToken ( ) ; if ( ! $ token || ! $ checker -> isGranted ( 'IS_AUTHENTICATED_REMEMBERED' ) ) { return ; } $ user = $ token -> getUser ( ) ; if ( $ user instanceof UserInterface ) { return [ 'id' => $ user -> getUsername ( ) ] ; } return [ 'id' => ( string ) $ user ] ; } ) ) ; }
Setup user detection.

@param \Bugsnag\Client    $client
@param \Silex\Application $app

@return void
Setup user detection .