<?php
namespace App\Entity\Slave;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="eposm_s_permission")
* @ORM\Entity
*/
class Permission
{
public function __toString(){
return $this->getValue();
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="slug", type="string", length=191, unique=true)
*/
protected $slug;
/**
* @ORM\Column(name="value", type="string", length=191)
*/
protected $value;
/**
* @ORM\Column(name="priority", type="integer")
*/
protected $priority;
// ManyToOne
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Slave\PermissionCategory", inversedBy="permissions")
* @ORM\JoinColumn(name="category_id", referencedColumnName="id")
*/
private $category;
//
// OneToMany
/**
* @ORM\OneToMany(targetEntity="App\Entity\Slave\JoinTableAccountTypePermission", mappedBy="permission")
*/
private $accountTypes;
public function __construct()
{
$this->accountTypes = new ArrayCollection();
}
//
public function getId(): ?string
{
return $this->id;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getValue(): ?string
{
return $this->value;
}
public function setValue(string $value): self
{
$this->value = $value;
return $this;
}
public function getPriority(): ?int
{
return $this->priority;
}
public function setPriority(int $priority): self
{
$this->priority = $priority;
return $this;
}
public function getCategory(): ?PermissionCategory
{
return $this->category;
}
public function setCategory(?PermissionCategory $category): self
{
$this->category = $category;
return $this;
}
/**
* @return Collection<int, JoinTableAccountTypePermission>
*/
public function getAccountTypes(): Collection
{
return $this->accountTypes;
}
public function addAccountType(JoinTableAccountTypePermission $accountType): self
{
if (!$this->accountTypes->contains($accountType)) {
$this->accountTypes->add($accountType);
$accountType->setPermission($this);
}
return $this;
}
public function removeAccountType(JoinTableAccountTypePermission $accountType): self
{
if ($this->accountTypes->removeElement($accountType)) {
// set the owning side to null (unless already changed)
if ($accountType->getPermission() === $this) {
$accountType->setPermission(null);
}
}
return $this;
}
}