<?php
namespace App\Entity\Security;
use App\Entity\Menu;
use App\Repository\Security\PermissionRepository;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=PermissionRepository::class)
*/
class Permission
{
const EDIT = 'edit';
const DELETE = 'delete';
const SHOW = 'show';
const LIST = 'list';
const NEW = 'new';
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=Menu::class, inversedBy="permissions", fetch="EAGER")
* @ORM\JoinColumn(nullable=false)
*/
private $menu;
/**
* @ORM\ManyToOne(targetEntity=Profile::class, inversedBy="permissions")
* @ORM\JoinColumn(nullable=false)
*/
private $profile;
/**
* @ORM\Column(type="array", nullable=true)
*/
private $actions = [];
public function getId(): ?int
{
return $this->id;
}
public function getMenu(): ?Menu
{
return $this->menu;
}
public function setMenu(?Menu $menu): self
{
$this->menu = $menu;
return $this;
}
public function getProfile(): ?Profile
{
return $this->profile;
}
public function setProfile(?Profile $profile): self
{
$this->profile = $profile;
return $this;
}
public function getActions(): ?array
{
return $this->actions;
}
public function setActions(?array $actions): self
{
$this->actions = $actions;
return $this;
}
public function __toString(): string
{
return implode(', ', $this->getActions());
}
}