From f67a9b770155357744482cb485a22ed9d1a0d2d0 Mon Sep 17 00:00:00 2001 From: Artem Vasilev Date: Thu, 14 Mar 2024 16:07:42 +0300 Subject: [PATCH] implement RequestAccessTokenEvent --- .../src/Event/RequestAccessTokenEvent.php | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 com_oauthserver/administrator/src/Event/RequestAccessTokenEvent.php diff --git a/com_oauthserver/administrator/src/Event/RequestAccessTokenEvent.php b/com_oauthserver/administrator/src/Event/RequestAccessTokenEvent.php new file mode 100644 index 0000000..5a4ba22 --- /dev/null +++ b/com_oauthserver/administrator/src/Event/RequestAccessTokenEvent.php @@ -0,0 +1,32 @@ + + * @license MIT; see LICENSE.txt + **/ + +namespace Webmasterskaya\Component\OauthServer\Administrator\Event; + +use League\OAuth2\Server\Entities\AccessTokenEntityInterface; + +class RequestAccessTokenEvent extends RequestEvent +{ + public function __construct(string $name, array $arguments = []) + { + if (!array_key_exists('accessToken', $arguments)) + { + throw new \BadMethodCallException("Argument 'accessToken' is required for event $name"); + } + + $this->setArgument('accessToken', $arguments['accessToken']); + + parent::__construct($name, $arguments); + } + + protected function onSetAccessToken(AccessTokenEntityInterface $accessToken): AccessTokenEntityInterface + { + return $accessToken; + } +}