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; + } +}