src/Entity/Permission.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PermissionRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Entity(repositoryClass=PermissionRepository::class)
  7.  * @ORM\Table(name="permission", uniqueConstraints={@ORM\UniqueConstraint(columns={"page_id","action_id"})})
  8.  */
  9. class Permission
  10. {
  11.     /**
  12.      * @ORM\Id
  13.      * @ORM\GeneratedValue
  14.      * @ORM\Column(type="integer")
  15.      */
  16.     private ?int $id null;
  17.     /**
  18.      * @ORM\ManyToOne(targetEntity=Page::class)
  19.      * @ORM\JoinColumn(name="page_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  20.      */
  21.     private ?Page $page null;
  22.     /**
  23.      * @ORM\ManyToOne(targetEntity=Action::class)
  24.      * @ORM\JoinColumn(name="action_id", referencedColumnName="id", nullable=false, onDelete="CASCADE")
  25.      */
  26.     private ?Action $action null;
  27.     public function getId(): ?int
  28.     {
  29.         return $this->id;
  30.     }
  31.     public function getPage(): ?Page
  32.     {
  33.         return $this->page;
  34.     }
  35.     public function setPage(Page $page): self
  36.     {
  37.         $this->page $page;
  38.         return $this;
  39.     }
  40.     public function getAction(): ?Action
  41.     {
  42.         return $this->action;
  43.     }
  44.     public function setAction(Action $action): self
  45.     {
  46.         $this->action $action;
  47.         return $this;
  48.     }
  49.     public function __toString(): string
  50.     {
  51.         return sprintf('%s:%s'$this->page?->getCode() ?? 'page'$this->action?->getCode() ?? 'action');
  52.     }
  53. }