<?php
namespace App\Entity;
use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
/**
* @Doctrine\ORM\Mapping\Entity
* @Doctrine\ORM\Mapping\Table(name="module")
*/
class Module implements BlameableInterface, TimestampableInterface, SoftDeletableInterface {
use BlameableTrait;
use TimestampableTrait;
use SoftDeletableTrait;
/**
* @Doctrine\ORM\Mapping\Id
* @Doctrine\ORM\Mapping\Column(type="integer")
* @Doctrine\ORM\Mapping\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @Doctrine\ORM\Mapping\Column(type="string", length=255)
*/
protected $name;
/**
* @Doctrine\ORM\Mapping\Column(name="code_name", type="string", length=255)
*/
protected $codeName;
/**
* @Doctrine\ORM\Mapping\OneToMany(targetEntity="UserGroupModule", mappedBy="module")
*/
protected $groupsModules;
/**
* Aktywny/nieakwtyny
* @Doctrine\ORM\Mapping\Column(type="boolean", options={"default"=0})
*/
protected $active;
/**
* Constructor
*/
public function __construct()
{
$this->groupsModules = new \Doctrine\Common\Collections\ArrayCollection();
}
public function __toString()
{
return $this->name;
}
public function getId(): ?int
{
return $this->id;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getCodeName(): ?string
{
return $this->codeName;
}
public function setCodeName(string $codeName): self
{
$this->codeName = $codeName;
return $this;
}
public function getActive(): ?bool
{
return $this->active;
}
public function setActive(bool $active): self
{
$this->active = $active;
return $this;
}
/**
* @return Collection|UserGroupModule[]
*/
public function getGroupsModules(): Collection
{
return $this->groupsModules;
}
public function addGroupsModule(UserGroupModule $groupsModule): self
{
if (!$this->groupsModules->contains($groupsModule)) {
$this->groupsModules[] = $groupsModule;
$groupsModule->setModule($this);
}
return $this;
}
public function removeGroupsModule(UserGroupModule $groupsModule): self
{
if ($this->groupsModules->contains($groupsModule)) {
$this->groupsModules->removeElement($groupsModule);
// set the owning side to null (unless already changed)
if ($groupsModule->getModule() === $this) {
$groupsModule->setModule(null);
}
}
return $this;
}
}