97 lines
2.2 KiB
PHP
97 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Entity;
|
|
|
|
use App\Repository\CommandGroupRepository;
|
|
use Doctrine\Common\Collections\ArrayCollection;
|
|
use Doctrine\Common\Collections\Collection;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
|
|
#[ORM\Entity(repositoryClass: CommandGroupRepository::class)]
|
|
class CommandGroup extends AbstractEntity
|
|
{
|
|
use NameableTrait;
|
|
use ToggleableTrait;
|
|
|
|
/**
|
|
* @var Collection<int, Command>
|
|
*/
|
|
#[ORM\ManyToMany(targetEntity: Command::class, inversedBy: 'commandGroups')]
|
|
private Collection $commands;
|
|
|
|
/**
|
|
* @var Collection<int, CommandTask>
|
|
*/
|
|
#[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<int, Command>
|
|
*/
|
|
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<int, CommandTask>
|
|
*/
|
|
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;
|
|
}
|
|
}
|