src/Entity/UserGroup.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Annotation\SiteAware;
  4. use App\Entity\Documents\Document;
  5. use App\Entity\Extranet\Alert;
  6. use App\Entity\Garages\GarageGroup;
  7. use App\Entity\Interfaces\SiteInterface;
  8. use App\Entity\OnlineShop\Family;
  9. use App\Entity\Traits\DescriptionTrait;
  10. use App\Entity\Traits\NameTrait;
  11. use App\Entity\Traits\SiteTrait;
  12. use App\Repository\UserGroupRepository;
  13. use Doctrine\Common\Collections\ArrayCollection;
  14. use Doctrine\Common\Collections\Collection;
  15. use Doctrine\ORM\Mapping as ORM;
  16. /**
  17.  * @ORM\Table(name="vulco_user_group")
  18.  * @ORM\Entity(repositoryClass=UserGroupRepository::class)
  19.  * @SiteAware(siteFieldName="site")
  20.  */
  21. class UserGroup extends MiniAbstractBase implements SiteInterface
  22. {
  23.     use DescriptionTrait;
  24.     use NameTrait;
  25.     use SiteTrait;
  26.     /**
  27.      * @ORM\Column(type="string", length=255, nullable=false)
  28.      */
  29.     private string $name;
  30.     /**
  31.      * @ORM\Column(type="text", length=10000, nullable=true)
  32.      */
  33.     private ?string $description null;
  34.     /**
  35.      * @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="userGroup")
  36.      */
  37.     private ?Collection $users;
  38.     /**
  39.      * @ORM\ManyToMany(targetEntity="App\Entity\Garages\GarageGroup", mappedBy="userGroups")
  40.      */
  41.     private ?Collection $garageGroups;
  42.     /**
  43.      * @ORM\ManyToMany(targetEntity="App\Entity\Extranet\Alert", mappedBy="userGroups")
  44.      */
  45.     private ?Collection $alerts;
  46.     /**
  47.      * @ORM\ManyToMany(targetEntity="App\Entity\Documents\Document", mappedBy="userGroups")
  48.      */
  49.     private ?Collection $documents;
  50.     /**
  51.      * @ORM\ManyToMany(targetEntity="App\Entity\OnlineShop\Family", mappedBy="userGroups")
  52.      */
  53.     private ?Collection $families;
  54.     /**
  55.      * @ORM\ManyToMany(targetEntity="App\Entity\OnlineShop\Family", mappedBy="userGroups")
  56.      */
  57.     private ?Collection $catalogGiftCategories;
  58.     public function __construct()
  59.     {
  60.         $this->users = new ArrayCollection();
  61.         $this->garageGroups = new ArrayCollection();
  62.         $this->alerts = new ArrayCollection();
  63.         $this->documents = new ArrayCollection();
  64.         $this->families = new ArrayCollection();
  65.         $this->catalogGiftCategories = new ArrayCollection();
  66.     }
  67.     public function getUsers(): ?Collection
  68.     {
  69.         return $this->users;
  70.     }
  71.     public function setUsers(?Collection $users): self
  72.     {
  73.         $this->users $users;
  74.         return $this;
  75.     }
  76.     public function addUser(User $user): self
  77.     {
  78.         if (!$this->users->contains($user)) {
  79.             $this->users->add($user);
  80.             $user->setUserGroup($this);
  81.         }
  82.         return $this;
  83.     }
  84.     public function removeUser(User $user): self
  85.     {
  86.         if ($this->users->contains($user)) {
  87.             $this->users->removeElement($user);
  88.             $user->setUserGroup(null);
  89.         }
  90.         return $this;
  91.     }
  92.     public function getGarageGroups(): ?Collection
  93.     {
  94.         return $this->garageGroups;
  95.     }
  96.     public function setGarageGroups(?Collection $garageGroups): ?Collection
  97.     {
  98.         $this->garageGroups $garageGroups;
  99.         return $this->garageGroups;
  100.     }
  101.     public function addGarageGroup(GarageGroup $garageGroup): self
  102.     {
  103.         if (!$this->garageGroups->contains($garageGroup)) {
  104.             $this->garageGroups->add($garageGroup);
  105.         }
  106.         return $this;
  107.     }
  108.     public function removeGarageGroup(GarageGroup $garageGroup): self
  109.     {
  110.         if ($this->garageGroups->contains($garageGroup)) {
  111.             $this->garageGroups->removeElement($garageGroup);
  112.         }
  113.         return $this;
  114.     }
  115.     public function getAlerts(): ?Collection
  116.     {
  117.         return $this->alerts;
  118.     }
  119.     public function setAlerts(?Collection $alerts): self
  120.     {
  121.         $this->alerts $alerts;
  122.         return $this;
  123.     }
  124.     public function addAlert(Alert $alert): self
  125.     {
  126.         if (!$this->alerts->contains($alert)) {
  127.             $this->alerts->add($alert);
  128.             $alert->addUserGroup($this);
  129.         }
  130.         return $this;
  131.     }
  132.     public function removeAlert(Alert $alert): self
  133.     {
  134.         if ($this->alerts->contains($alert)) {
  135.             $this->alerts->removeElement($alert);
  136.         }
  137.         return $this;
  138.     }
  139.     public function getDocuments(): ?Collection
  140.     {
  141.         return $this->documents;
  142.     }
  143.     public function setDocuments(?Collection $documents): self
  144.     {
  145.         $this->documents $documents;
  146.         return $this;
  147.     }
  148.     public function addDocument(Document $document): self
  149.     {
  150.         if (!$this->documents->contains($document)) {
  151.             $this->documents->add($document);
  152.             $document->addUserGroup($this);
  153.         }
  154.         return $this;
  155.     }
  156.     public function removeDocument(Document $document): self
  157.     {
  158.         if ($this->documents->contains($document)) {
  159.             $this->documents->removeElement($document);
  160.         }
  161.         return $this;
  162.     }
  163.     public function getFamilies(): ?Collection
  164.     {
  165.         return $this->families;
  166.     }
  167.     public function setFamilies(?Collection $families): self
  168.     {
  169.         $this->families $families;
  170.         return $this;
  171.     }
  172.     public function addFamilie(Family $family): self
  173.     {
  174.         if (!$this->families->contains($family)) {
  175.             $this->families->add($family);
  176.             $family->addUserGroup($this);
  177.         }
  178.         return $this;
  179.     }
  180.     public function removeFamily(Family $family): self
  181.     {
  182.         if ($this->families->contains($family)) {
  183.             $this->families->removeElement($family);
  184.         }
  185.         return $this;
  186.     }
  187.     public function getCatalogGiftCategories(): ?Collection
  188.     {
  189.         return $this->catalogGiftCategories;
  190.     }
  191.     public function setCatalogGiftCategories(?Collection $catalogGiftCategories): self
  192.     {
  193.         $this->catalogGiftCategories $catalogGiftCategories;
  194.         return $this;
  195.     }
  196.     public function addCatalogGiftCategory(Family $family): self
  197.     {
  198.         if (!$this->catalogGiftCategories->contains($family)) {
  199.             $this->catalogGiftCategories->add($family);
  200.             $family->addUserGroup($this);
  201.         }
  202.         return $this;
  203.     }
  204.     public function removeCatalogGiftCategory(Family $family): self
  205.     {
  206.         if ($this->catalogGiftCategories->contains($family)) {
  207.             $this->catalogGiftCategories->removeElement($family);
  208.         }
  209.         return $this;
  210.     }
  211.     public function __toString(): string
  212.     {
  213.         return $this->id $this->getName() : MiniAbstractBase::DEFAULT_EMPTY_STRING;
  214.     }
  215. }