<?php
namespace App\Entity;
use App\Repository\AnalysisServiceGroupRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Blameable\Traits\BlameableEntity;
use Gedmo\Timestampable\Traits\TimestampableEntity;
#[ORM\Entity(repositoryClass: AnalysisServiceGroupRepository::class)]
class AnalysisServiceGroup
{
use BlameableEntity;
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\OneToMany(mappedBy: 'group', targetEntity: AnalysisServiceGroupService::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
private Collection $groupServices;
#[ORM\Column(type: 'string', length: 255)]
private $groupName;
#[ORM\ManyToOne(targetEntity: Company::class, inversedBy: 'selectedAnalysisServiceGroups')]
private $company;
public function __construct()
{
$this->groupServices = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
/**
* @return Collection<int, AnalysisServiceGroupService>
*/
public function getGroupServices(): Collection
{
return $this->groupServices;
}
public function addGroupService(AnalysisServiceGroupService $groupService): self
{
if (!$this->groupServices->contains($groupService)) {
$this->groupServices[] = $groupService;
$groupService->setGroup($this);
}
return $this;
}
public function removeGroupService(AnalysisServiceGroupService $groupService): self
{
if ($this->groupServices->removeElement($groupService)) {
if ($groupService->getGroup() === $this) {
$groupService->setGroup(null);
}
}
return $this;
}
// For backward compatibility and easier transition
public function getServices(): Collection
{
return $this->groupServices->map(fn(AnalysisServiceGroupService $gs) => $gs->getService());
}
public function getGroupName(): ?string
{
return $this->groupName;
}
public function setGroupName(string $groupName): self
{
$this->groupName = $groupName;
return $this;
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
}