src/Entity/AnalysisServiceGroup.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\AnalysisServiceGroupRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Gedmo\Blameable\Traits\BlameableEntity;
  8. use Gedmo\Timestampable\Traits\TimestampableEntity;
  9. #[ORM\Entity(repositoryClass: AnalysisServiceGroupRepository::class)]
  10. class AnalysisServiceGroup
  11. {
  12. use BlameableEntity;
  13. use TimestampableEntity;
  14. #[ORM\Id]
  15. #[ORM\GeneratedValue]
  16. #[ORM\Column(type: 'integer')]
  17. private $id;
  18. #[ORM\OneToMany(mappedBy: 'group', targetEntity: AnalysisServiceGroupService::class, cascade: ['persist', 'remove'], orphanRemoval: true)]
  19. private Collection $groupServices;
  20. #[ORM\Column(type: 'string', length: 255)]
  21. private $groupName;
  22. #[ORM\ManyToOne(targetEntity: Company::class, inversedBy: 'selectedAnalysisServiceGroups')]
  23. private $company;
  24. public function __construct()
  25. {
  26. $this->groupServices = new ArrayCollection();
  27. }
  28. public function getId(): ?int
  29. {
  30. return $this->id;
  31. }
  32. /**
  33. * @return Collection<int, AnalysisServiceGroupService>
  34. */
  35. public function getGroupServices(): Collection
  36. {
  37. return $this->groupServices;
  38. }
  39. public function addGroupService(AnalysisServiceGroupService $groupService): self
  40. {
  41. if (!$this->groupServices->contains($groupService)) {
  42. $this->groupServices[] = $groupService;
  43. $groupService->setGroup($this);
  44. }
  45. return $this;
  46. }
  47. public function removeGroupService(AnalysisServiceGroupService $groupService): self
  48. {
  49. if ($this->groupServices->removeElement($groupService)) {
  50. if ($groupService->getGroup() === $this) {
  51. $groupService->setGroup(null);
  52. }
  53. }
  54. return $this;
  55. }
  56. // For backward compatibility and easier transition
  57. public function getServices(): Collection
  58. {
  59. return $this->groupServices->map(fn(AnalysisServiceGroupService $gs) => $gs->getService());
  60. }
  61. public function getGroupName(): ?string
  62. {
  63. return $this->groupName;
  64. }
  65. public function setGroupName(string $groupName): self
  66. {
  67. $this->groupName = $groupName;
  68. return $this;
  69. }
  70. public function getCompany(): ?Company
  71. {
  72. return $this->company;
  73. }
  74. public function setCompany(?Company $company): self
  75. {
  76. $this->company = $company;
  77. return $this;
  78. }
  79. }