src/Entity/ParameterHook.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ParameterHookRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use JMS\Serializer\Annotation as Serializer;
  8. use JMS\Serializer\Annotation\Expose;
  9. use JMS\Serializer\Annotation\Groups;
  10. /**
  11. * @ORM\Entity(repositoryClass=ParameterHookRepository::class)
  12. *
  13. * @Serializer\ExclusionPolicy("ALL")
  14. */
  15. class ParameterHook
  16. {
  17. /**
  18. * @ORM\Id
  19. * @ORM\GeneratedValue
  20. * @ORM\Column(type="integer")
  21. *
  22. * @Expose
  23. * @Groups({"parameter"})
  24. */
  25. private $id;
  26. /**
  27. * @ORM\Column(type="string", length=255)
  28. *
  29. * @Expose
  30. * @Groups({"parameter"})
  31. */
  32. private $slug;
  33. /**
  34. * @ORM\Column(type="string", length=255, nullable=true)
  35. *
  36. * @Expose
  37. * @Groups({"parameter"})
  38. */
  39. private $name;
  40. /**
  41. * @ORM\OneToMany(targetEntity=Parameter::class, mappedBy="parameterHook")
  42. */
  43. private $parameters;
  44. /**
  45. * @ORM\Column(type="string", length=255, nullable=true)
  46. */
  47. private $displayJob;
  48. /**
  49. * @ORM\Column(type="string", length=255, nullable=true)
  50. */
  51. private $displayRole;
  52. public function __construct()
  53. {
  54. $this->parameters = new ArrayCollection();
  55. }
  56. public function getId(): ?int
  57. {
  58. return $this->id;
  59. }
  60. public function getSlug(): ?string
  61. {
  62. return $this->slug;
  63. }
  64. public function setSlug(string $slug): self
  65. {
  66. $this->slug = $slug;
  67. return $this;
  68. }
  69. public function getName(): ?string
  70. {
  71. return $this->name;
  72. }
  73. public function setName(?string $name): self
  74. {
  75. $this->name = $name;
  76. return $this;
  77. }
  78. /**
  79. * @return Collection<int, Parameter>
  80. */
  81. public function getParameters(): Collection
  82. {
  83. return $this->parameters;
  84. }
  85. public function addParameter(Parameter $parameter): self
  86. {
  87. if(!$this->parameters->contains($parameter))
  88. {
  89. $this->parameters[] = $parameter;
  90. $parameter->setParameterHook($this);
  91. }
  92. return $this;
  93. }
  94. public function removeParameter(Parameter $parameter): self
  95. {
  96. if($this->parameters->removeElement($parameter))
  97. {
  98. // set the owning side to null (unless already changed)
  99. if($parameter->getParameterHook() === $this)
  100. {
  101. $parameter->setParameterHook(NULL);
  102. }
  103. }
  104. return $this;
  105. }
  106. public function getDisplayRole(): ?array
  107. {
  108. if($this->displayRole === NULL)
  109. {
  110. return $this->displayRole;
  111. }
  112. return explode(';', $this->displayRole);
  113. }
  114. public function setDisplayRole(?array $displayRole): self
  115. {
  116. if($displayRole === [])
  117. {
  118. $this->displayRole = NULL;
  119. }
  120. else
  121. {
  122. $this->displayRole = implode(';', $displayRole);
  123. }
  124. return $this;
  125. }
  126. public function getDisplayJob(): ?array
  127. {
  128. if($this->displayJob === NULL)
  129. {
  130. return $this->displayJob;
  131. }
  132. return explode(';', $this->displayJob);
  133. }
  134. public function setDisplayJob(?array $displayJob): self
  135. {
  136. if($displayJob === [])
  137. {
  138. $this->displayJob = NULL;
  139. }
  140. else
  141. {
  142. $this->displayJob = implode(';', $displayJob);
  143. }
  144. return $this;
  145. }
  146. }