forked from OxCom/symfony-rollbar-bundle
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Possibility to use service as person_fn rather than a static function
- Loading branch information
1 parent
d9cb06f
commit 63e0453
Showing
5 changed files
with
57 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
namespace Rollbar\Symfony\RollbarBundle\Service; | ||
|
||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; | ||
use Symfony\Component\Serializer\Normalizer\NormalizerInterface; | ||
|
||
class PersonProvider implements PersonProviderInterface | ||
{ | ||
public function __construct( | ||
private TokenStorageInterface $tokenStorage, | ||
private NormalizerInterface $normalizer, | ||
) {} | ||
|
||
public function getUserInfo(): array | ||
{ | ||
$token = $this->tokenStorage->getToken(); | ||
|
||
if ($token) { | ||
$user = $token->getUser(); | ||
|
||
return $this->normalizer->normalize($user, 'json'); | ||
} | ||
|
||
return []; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?php | ||
|
||
namespace Rollbar\Symfony\RollbarBundle\Service; | ||
|
||
interface PersonProviderInterface | ||
{ | ||
public function getUserInfo(): array; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters