src/Entity/CompanyGroup.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\CompanyRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=CompanyRepository::class)
  9.  * @ORM\HasLifecycleCallbacks
  10.  */
  11. class CompanyGroup extends Company
  12. {
  13.     const TYPE 'type_group';
  14.     /**
  15.      * @return Collection<int, self>
  16.      */
  17.     public function getCompanyGroupCompanies(): Collection
  18.     {
  19.         return $this->companyGroupCompanies;
  20.     }
  21.     public function addCompanyToGroup(self $companyGroup): self
  22.     {
  23.         if (!$this->companyGroupCompanies->contains($companyGroup)) {
  24.             $this->companyGroupCompanies[] = $companyGroup;
  25.             $companyGroup->setCompanyGroup($this);
  26.         }
  27.         return $this;
  28.     }
  29.     public function removeCompanyFromGroup(self $companyGroup): self
  30.     {
  31.         if ($this->companyGroupCompanies->removeElement($companyGroup)) {
  32.             // set the owning side to null (unless already changed)
  33.             if ($companyGroup->getCompanyGroup() === $this) {
  34.                 $companyGroup->setCompanyGroup(null);
  35.             }
  36.         }
  37.         return $this;
  38.     }
  39. }