<?php
namespace App\Entity\OAuth2\App;
use Doctrine\ORM\Mapping as ORM;
use League\OAuth2\Server\Entities\AccessTokenEntityInterface;
use League\OAuth2\Server\Entities\ClientEntityInterface;
use League\OAuth2\Server\Entities\ScopeEntityInterface;
use League\OAuth2\Server\Entities\Traits\AccessTokenTrait;
/**
* @ORM\Entity(
* repositoryClass = "App\Doctrine\Repository\OAuth2\App\AppAccessTokenRepository",
* )
*/
class AppAccessToken extends AbstractAppToken implements AccessTokenEntityInterface
{
public const DISCR = 'app.access';
use AccessTokenTrait;
/**
* @param ClientEntityInterface $client
* @param array $scopes
* @param string|null $userIdentifier
*/
public function __construct(
ClientEntityInterface $client,
array $scopes,
?string $userIdentifier = null,
)
{
$this->client = $client->getIdentifier();
$this->scopes = array_map(
static function (ScopeEntityInterface $scope) {
return $scope->getIdentifier();
},
$scopes,
);
$this->userIdentifier = $userIdentifier;
}
}