. */ namespace App\Entity\Parameters; use Doctrine\Common\Collections\Collection; use Symfony\Component\Validator\Constraints as Assert; trait ParametersTrait { /** * Mapping done in subclasses. * * @var AbstractParameter[]|Collection * @Assert\Valid() */ protected $parameters; /** * Return all associated specifications. * * @return AbstractParameter[]|Collection */ public function getParameters(): Collection { return $this->parameters; } /** * Add a new parameter information. * * @return $this */ public function addParameter(AbstractParameter $parameter): self { $parameter->setElement($this); $this->parameters->add($parameter); return $this; } public function removeParameter(AbstractParameter $parameter): self { $this->parameters->removeElement($parameter); return $this; } public function getGroupedParameters(): array { $tmp = []; foreach ($this->parameters as $parameter) { $tmp[$parameter->getGroup()][] = $parameter; } return $tmp; } }