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. $this->parameters[] = $parameter;
  89. $parameter->setParameterHook( $this );
  90. }
  91. return $this;
  92. }
  93. public function removeParameter( Parameter $parameter ): self
  94. {
  95. if ( $this->parameters->removeElement( $parameter ) ) {
  96. // set the owning side to null (unless already changed)
  97. if ( $parameter->getParameterHook() === $this ) {
  98. $parameter->setParameterHook( NULL );
  99. }
  100. }
  101. return $this;
  102. }
  103. public function getDisplayRole(): ?array
  104. {
  105. if ( $this->displayRole === NULL ) {
  106. return $this->displayRole;
  107. }
  108. return explode( ';', $this->displayRole );
  109. }
  110. public function setDisplayRole( ?array $displayRole ): self
  111. {
  112. if ( $displayRole === [] ) {
  113. $this->displayRole = NULL;
  114. }
  115. else {
  116. $this->displayRole = implode( ';', $displayRole );
  117. }
  118. return $this;
  119. }
  120. public function getDisplayJob(): ?array
  121. {
  122. if ( $this->displayJob === NULL ) {
  123. return $this->displayJob;
  124. }
  125. return explode( ';', $this->displayJob );
  126. }
  127. public function setDisplayJob( ?array $displayJob ): self
  128. {
  129. if ( $displayJob === [] ) {
  130. $this->displayJob = NULL;
  131. }
  132. else {
  133. $this->displayJob = implode( ';', $displayJob );
  134. }
  135. return $this;
  136. }
  137. }