src/Entity/OAuth2/Scope.php line 71

Open in your IDE?
  1. <?php
  2. namespace App\Entity\OAuth2;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use League\OAuth2\Server\Entities\ScopeEntityInterface;
  6. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  7. use App\Repository\OAuth2\ScopeRepository;
  8. /**
  9.  * @ORM\Table(name="oauth2_scope")
  10.  * @ORM\Entity(repositoryClass=ScopeRepository::class)
  11.  * @UniqueEntity(fields={"identifier"}, message="There is already a scope with tis identifier")
  12.  */
  13. class Scope implements ScopeEntityInterface
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\Column(name="id", type="guid")
  18.      * @ORM\GeneratedValue(strategy="UUID")
  19.      */
  20.     private $identifier;
  21.     /**
  22.      * @ORM\Column(type="datetime")
  23.      */
  24.     private $creationDatetime;
  25.     /**
  26.      * @ORM\Column(type="string")
  27.      */
  28.     protected $scope;
  29.     public function __construct()
  30.     {
  31.         $this->creationDatetime = new DateTime();
  32.     }
  33.     /**
  34.      * @return mixed
  35.      */
  36.     public function getIdentifier()
  37.     {
  38.         return $this->identifier;
  39.     }
  40.     /**
  41.      * @return DateTime
  42.      */
  43.     public function getCreationDatetime(): DateTime
  44.     {
  45.         return $this->creationDatetime;
  46.     }
  47.     /**
  48.      * @param DateTime $creationDatetime
  49.      *
  50.      * @return $this
  51.      */
  52.     public function setCreationDatetime(DateTime $creationDatetime): Scope
  53.     {
  54.         $this->creationDatetime $creationDatetime;
  55.         return $this;
  56.     }
  57.     /**
  58.      * {@inheritdoc}
  59.      */
  60.     public function jsonSerialize()
  61.     {
  62.         return $this->getIdentifier();
  63.     }
  64.     public function __toString(): string
  65.     {
  66.         return $this->scope;
  67.     }
  68.     /**
  69.      * @return string
  70.      */
  71.     public function getScope(): string
  72.     {
  73.         return $this->scope;
  74.     }
  75.     /**
  76.      * @param mixed $scope
  77.      *
  78.      * @return $this
  79.      */
  80.     public function setScope(string $scope): Scope
  81.     {
  82.         $this->scope $scope;
  83.         return $this;
  84.     }
  85. }