src/Entity/Module.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Knp\DoctrineBehaviors\Contract\Entity\SoftDeletableInterface;
  4. use Knp\DoctrineBehaviors\Model\SoftDeletable\SoftDeletableTrait;
  5. use Knp\DoctrineBehaviors\Contract\Entity\TimestampableInterface;
  6. use Knp\DoctrineBehaviors\Model\Timestampable\TimestampableTrait;
  7. use Knp\DoctrineBehaviors\Contract\Entity\BlameableInterface;
  8. use Knp\DoctrineBehaviors\Model\Blameable\BlameableTrait;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use Doctrine\Common\Collections\Collection;
  11. /**
  12.  * @Doctrine\ORM\Mapping\Entity
  13.  * @Doctrine\ORM\Mapping\Table(name="module")
  14.  */
  15. class Module implements BlameableInterfaceTimestampableInterfaceSoftDeletableInterface  {
  16.     use BlameableTrait;
  17.     use TimestampableTrait;
  18.     
  19.     use SoftDeletableTrait;
  20.     
  21. /**
  22.      * @Doctrine\ORM\Mapping\Id
  23.      * @Doctrine\ORM\Mapping\Column(type="integer")
  24.      * @Doctrine\ORM\Mapping\GeneratedValue(strategy="AUTO")
  25.      */
  26.     protected $id;
  27.     /**
  28.      * @Doctrine\ORM\Mapping\Column(type="string", length=255)
  29.      */
  30.     protected $name;
  31.     /**
  32.      * @Doctrine\ORM\Mapping\Column(name="code_name", type="string", length=255)
  33.      */
  34.     protected $codeName;
  35.     /**
  36.      * @Doctrine\ORM\Mapping\OneToMany(targetEntity="UserGroupModule", mappedBy="module")
  37.      */
  38.     protected $groupsModules;
  39.     /**
  40.      * Aktywny/nieakwtyny
  41.      * @Doctrine\ORM\Mapping\Column(type="boolean", options={"default"=0})
  42.      */
  43.     protected $active;
  44.     /**
  45.      * Constructor
  46.      */
  47.     public function __construct()
  48.     {
  49.         $this->groupsModules = new \Doctrine\Common\Collections\ArrayCollection();
  50.     }
  51.     public function __toString()
  52.     {
  53.         return $this->name;
  54.     }
  55.     public function getId(): ?int
  56.     {
  57.         return $this->id;
  58.     }
  59.     public function getName(): ?string
  60.     {
  61.         return $this->name;
  62.     }
  63.     public function setName(string $name): self
  64.     {
  65.         $this->name $name;
  66.         return $this;
  67.     }
  68.     public function getCodeName(): ?string
  69.     {
  70.         return $this->codeName;
  71.     }
  72.     public function setCodeName(string $codeName): self
  73.     {
  74.         $this->codeName $codeName;
  75.         return $this;
  76.     }
  77.     public function getActive(): ?bool
  78.     {
  79.         return $this->active;
  80.     }
  81.     public function setActive(bool $active): self
  82.     {
  83.         $this->active $active;
  84.         return $this;
  85.     }
  86.     /**
  87.      * @return Collection|UserGroupModule[]
  88.      */
  89.     public function getGroupsModules(): Collection
  90.     {
  91.         return $this->groupsModules;
  92.     }
  93.     public function addGroupsModule(UserGroupModule $groupsModule): self
  94.     {
  95.         if (!$this->groupsModules->contains($groupsModule)) {
  96.             $this->groupsModules[] = $groupsModule;
  97.             $groupsModule->setModule($this);
  98.         }
  99.         return $this;
  100.     }
  101.     public function removeGroupsModule(UserGroupModule $groupsModule): self
  102.     {
  103.         if ($this->groupsModules->contains($groupsModule)) {
  104.             $this->groupsModules->removeElement($groupsModule);
  105.             // set the owning side to null (unless already changed)
  106.             if ($groupsModule->getModule() === $this) {
  107.                 $groupsModule->setModule(null);
  108.             }
  109.         }
  110.         return $this;
  111.     }
  112. }