src/Entity/Permission.php line 12

  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use App\Repository\PermissionRepository;
  7. use Doctrine\Common\Collections\Collection;
  8. #[ORM\Entity(repositoryClassPermissionRepository::class)]
  9. class Permission
  10. {
  11.   #[ORM\Id]
  12.   #[ORM\GeneratedValue]
  13.   #[ORM\Column()]
  14.   private ?int $id null;
  15.   #[ORM\Column]
  16.   #[Gedmo\Timestampable(on'create')]
  17.   private ?\DateTimeImmutable $createdAt null;
  18.   #[ORM\Column(length255)]
  19.   private ?string $title null;
  20.   #[ORM\Column(length255)]
  21.   private ?string $label null;
  22.   #[ORM\Column(nullabletrue)]
  23.   private ?int $authorId null;
  24.   #[ORM\ManyToMany(targetEntityRole::class, inversedBy'permissions')]
  25.   private ?Collection $roles null;
  26.   #[ORM\Column]
  27.   private array $MetaData = [];
  28.   public function __construct()
  29.   {
  30.     $this->roles = new ArrayCollection();
  31.   }
  32.   public function getId(): ?int
  33.   {
  34.     return $this->id;
  35.   }
  36.   public function getCreatedAt(): ?\DateTimeImmutable
  37.   {
  38.     return $this->createdAt;
  39.   }
  40.   public function setCreatedAt(\DateTimeImmutable $createdAt): self
  41.   {
  42.     $this->createdAt $createdAt;
  43.     return $this;
  44.   }
  45.   public function getTitle(): ?string
  46.   {
  47.     return $this->title;
  48.   }
  49.   public function setTitle(string $title): self
  50.   {
  51.     $this->title $title;
  52.     return $this;
  53.   }
  54.   public function getLabel(): ?string
  55.   {
  56.     return $this->label;
  57.   }
  58.   public function setLabel(string $label): self
  59.   {
  60.     $this->label $label;
  61.     return $this;
  62.   }
  63.   public function getAuthorId(): ?int
  64.   {
  65.     return $this->authorId;
  66.   }
  67.   public function setAuthorId(?int $authorId): self
  68.   {
  69.     $this->authorId $authorId;
  70.     return $this;
  71.   }
  72.   public function getMetaData(): array
  73.   {
  74.     return $this->MetaData;
  75.   }
  76.   public function setMetaData(array $MetaData): self
  77.   {
  78.     $this->MetaData $MetaData;
  79.     return $this;
  80.   }
  81.   /**
  82.    * @return Collection<int, Role>
  83.    */
  84.   public function getRoles(): Collection
  85.   {
  86.     return $this->roles;
  87.   }
  88.   public function addRole(Role $role): self
  89.   {
  90.     if (!$this->roles->contains($role)) {
  91.       $this->roles->add($role);
  92.     }
  93.     return $this;
  94.   }
  95.   public function removeRole(Role $role): self
  96.   {
  97.     $this->roles->removeElement($role);
  98.     return $this;
  99.   }
  100. }