*/ #[ORM\ManyToMany(targetEntity: Command::class, inversedBy: 'commandGroups')] private Collection $commands; /** * @var Collection */ #[ORM\ManyToMany(targetEntity: CommandTask::class, mappedBy: 'commandGroups')] private Collection $commandTasks; public function __construct() { parent::__construct(); $this->commands = new ArrayCollection(); $this->commandTasks = new ArrayCollection(); } /** * @return Collection */ public function getCommands(): Collection { return $this->commands; } public function setCommands(array $commands): static { $this->commands->clear(); foreach ($commands as $command){ $this->addCommand($command); } return $this; } public function addCommand(Command $command): static { if (!$this->commands->contains($command)) { $this->commands->add($command); } return $this; } public function removeCommand(Command $command): static { $this->commands->removeElement($command); return $this; } /** * @return Collection */ public function getCommandTasks(): Collection { return $this->commandTasks; } public function addCommandTask(CommandTask $commandTask): static { if (!$this->commandTasks->contains($commandTask)) { $this->commandTasks->add($commandTask); $commandTask->addCommandGroup($this); } return $this; } public function removeCommandTask(CommandTask $commandTask): static { if ($this->commandTasks->removeElement($commandTask)) { $commandTask->removeCommandGroup($this); } return $this; } }