src/Entity/ParameterCategory.php line 11

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ParameterCategoryRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. #[ORM\Entity(repositoryClass: ParameterCategoryRepository::class)]
  8. class ParameterCategory
  9. {
  10. #[ORM\Id]
  11. #[ORM\GeneratedValue]
  12. #[ORM\Column(type: 'integer')]
  13. private $id;
  14. #[ORM\Column(type: 'string', length: 255, nullable: true)]
  15. private $name;
  16. #[ORM\OneToMany(targetEntity: Parameter::class, mappedBy: 'parameterCategory')]
  17. private $parameters;
  18. public function __construct()
  19. {
  20. $this->parameters = new ArrayCollection();
  21. }
  22. public function getId(): ?int
  23. {
  24. return $this->id;
  25. }
  26. public function getName(): ?string
  27. {
  28. return $this->name;
  29. }
  30. public function setName(?string $name): self
  31. {
  32. $this->name = $name;
  33. return $this;
  34. }
  35. /**
  36. * @return Collection|Parameter[]
  37. */
  38. public function getParameters(): Collection
  39. {
  40. return $this->parameters;
  41. }
  42. public function addParameter(Parameter $parameter): self
  43. {
  44. if (!$this->parameters->contains($parameter)) {
  45. $this->parameters[] = $parameter;
  46. $parameter->setParameterCategory($this);
  47. }
  48. return $this;
  49. }
  50. public function removeParameter(Parameter $parameter): self
  51. {
  52. if ($this->parameters->removeElement($parameter)) {
  53. // set the owning side to null (unless already changed)
  54. if ($parameter->getParameterCategory() === $this) {
  55. $parameter->setParameterCategory(null);
  56. }
  57. }
  58. return $this;
  59. }
  60. }