<?php
namespace App\Entity;
use App\Annotation\SiteAware;
use App\Entity\Documents\Document;
use App\Entity\Extranet\Alert;
use App\Entity\Garages\GarageGroup;
use App\Entity\Interfaces\SiteInterface;
use App\Entity\OnlineShop\Family;
use App\Entity\Traits\DescriptionTrait;
use App\Entity\Traits\NameTrait;
use App\Entity\Traits\SiteTrait;
use App\Repository\UserGroupRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="vulco_user_group")
* @ORM\Entity(repositoryClass=UserGroupRepository::class)
* @SiteAware(siteFieldName="site")
*/
class UserGroup extends MiniAbstractBase implements SiteInterface
{
use DescriptionTrait;
use NameTrait;
use SiteTrait;
/**
* @ORM\Column(type="string", length=255, nullable=false)
*/
private string $name;
/**
* @ORM\Column(type="text", length=10000, nullable=true)
*/
private ?string $description = null;
/**
* @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="userGroup")
*/
private ?Collection $users;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Garages\GarageGroup", mappedBy="userGroups")
*/
private ?Collection $garageGroups;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Extranet\Alert", mappedBy="userGroups")
*/
private ?Collection $alerts;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\Documents\Document", mappedBy="userGroups")
*/
private ?Collection $documents;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\OnlineShop\Family", mappedBy="userGroups")
*/
private ?Collection $families;
/**
* @ORM\ManyToMany(targetEntity="App\Entity\OnlineShop\Family", mappedBy="userGroups")
*/
private ?Collection $catalogGiftCategories;
public function __construct()
{
$this->users = new ArrayCollection();
$this->garageGroups = new ArrayCollection();
$this->alerts = new ArrayCollection();
$this->documents = new ArrayCollection();
$this->families = new ArrayCollection();
$this->catalogGiftCategories = new ArrayCollection();
}
public function getUsers(): ?Collection
{
return $this->users;
}
public function setUsers(?Collection $users): self
{
$this->users = $users;
return $this;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users->add($user);
$user->setUserGroup($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
$user->setUserGroup(null);
}
return $this;
}
public function getGarageGroups(): ?Collection
{
return $this->garageGroups;
}
public function setGarageGroups(?Collection $garageGroups): ?Collection
{
$this->garageGroups = $garageGroups;
return $this->garageGroups;
}
public function addGarageGroup(GarageGroup $garageGroup): self
{
if (!$this->garageGroups->contains($garageGroup)) {
$this->garageGroups->add($garageGroup);
}
return $this;
}
public function removeGarageGroup(GarageGroup $garageGroup): self
{
if ($this->garageGroups->contains($garageGroup)) {
$this->garageGroups->removeElement($garageGroup);
}
return $this;
}
public function getAlerts(): ?Collection
{
return $this->alerts;
}
public function setAlerts(?Collection $alerts): self
{
$this->alerts = $alerts;
return $this;
}
public function addAlert(Alert $alert): self
{
if (!$this->alerts->contains($alert)) {
$this->alerts->add($alert);
$alert->addUserGroup($this);
}
return $this;
}
public function removeAlert(Alert $alert): self
{
if ($this->alerts->contains($alert)) {
$this->alerts->removeElement($alert);
}
return $this;
}
public function getDocuments(): ?Collection
{
return $this->documents;
}
public function setDocuments(?Collection $documents): self
{
$this->documents = $documents;
return $this;
}
public function addDocument(Document $document): self
{
if (!$this->documents->contains($document)) {
$this->documents->add($document);
$document->addUserGroup($this);
}
return $this;
}
public function removeDocument(Document $document): self
{
if ($this->documents->contains($document)) {
$this->documents->removeElement($document);
}
return $this;
}
public function getFamilies(): ?Collection
{
return $this->families;
}
public function setFamilies(?Collection $families): self
{
$this->families = $families;
return $this;
}
public function addFamilie(Family $family): self
{
if (!$this->families->contains($family)) {
$this->families->add($family);
$family->addUserGroup($this);
}
return $this;
}
public function removeFamily(Family $family): self
{
if ($this->families->contains($family)) {
$this->families->removeElement($family);
}
return $this;
}
public function getCatalogGiftCategories(): ?Collection
{
return $this->catalogGiftCategories;
}
public function setCatalogGiftCategories(?Collection $catalogGiftCategories): self
{
$this->catalogGiftCategories = $catalogGiftCategories;
return $this;
}
public function addCatalogGiftCategory(Family $family): self
{
if (!$this->catalogGiftCategories->contains($family)) {
$this->catalogGiftCategories->add($family);
$family->addUserGroup($this);
}
return $this;
}
public function removeCatalogGiftCategory(Family $family): self
{
if ($this->catalogGiftCategories->contains($family)) {
$this->catalogGiftCategories->removeElement($family);
}
return $this;
}
public function __toString(): string
{
return $this->id ? $this->getName() : MiniAbstractBase::DEFAULT_EMPTY_STRING;
}
}