src/Entity/Hymntypes.php line 15

Open in your IDE?
  1. <?php namespace App\Entity;
  2. use DateTime;
  3. use DateTimeInterface;
  4. use Doctrine\Common\Collections\{ArrayCollection, Collection};
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Gedmo\Mapping\Annotation as Gedmo;
  7. /**
  8. * Hymntypes
  9. *
  10. * @ORM\Table(name="hymntypes")
  11. * @ORM\Entity
  12. */
  13. class Hymntypes
  14. {
  15. /**
  16. * @var int
  17. *
  18. * @ORM\Column(type="integer", name="id")
  19. * @ORM\Id
  20. * @ORM\GeneratedValue(strategy="IDENTITY")
  21. */
  22. private int $id;
  23. /**
  24. * @var string
  25. *
  26. * @ORM\Column(type="string", length=255, nullable=false, name="title")
  27. */
  28. private string $title;
  29. /**
  30. * @Gedmo\Slug(fields={"title","slug"})
  31. * @ORM\Column(unique=true, length=128, nullable=false)
  32. */
  33. private ?string $slug;
  34. /**
  35. * @var string|null
  36. *
  37. * @ORM\Column(type="text", length=65535, nullable=true, name="description")
  38. */
  39. private ?string $description;
  40. /**
  41. * @var DateTime|null
  42. *
  43. * @ORM\Column(type="datetime", nullable=true, name="created_at")
  44. */
  45. private ?DateTime $created_at;
  46. /**
  47. * @var DateTime|null
  48. *
  49. * @ORM\Column(type="datetime", nullable=true, name="updated_at")
  50. */
  51. private ?DateTime $updated_at;
  52. /**
  53. * @ORM\OneToMany(targetEntity="App\Entity\Hymns", mappedBy="type", cascade={"persist"})
  54. * @ORM\JoinColumn(nullable=false, referencedColumnName="id")
  55. */
  56. private Collection $hymns;
  57. /**
  58. * Hymntypes constructor.
  59. */
  60. public function __construct()
  61. {
  62. $this->hymns = new ArrayCollection();
  63. }
  64. /**
  65. * @return int|null
  66. */
  67. public function getId(): ?int
  68. {
  69. return $this->id;
  70. }
  71. /**
  72. * @return string|null
  73. */
  74. public function getTitle(): ?string
  75. {
  76. return $this->title;
  77. }
  78. /**
  79. * @param string $title
  80. *
  81. * @return $this
  82. */
  83. public function setTitle(string $title): self
  84. {
  85. $this->title = $title;
  86. return $this;
  87. }
  88. /**
  89. * @return string|null
  90. */
  91. public function getSlug(): ?string
  92. {
  93. return $this->slug;
  94. }
  95. /**
  96. * @param string $slug
  97. *
  98. * @return $this
  99. */
  100. public function setSlug(string $slug): self
  101. {
  102. $this->slug = $slug;
  103. return $this;
  104. }
  105. /**
  106. * @return string|null
  107. */
  108. public function getDescription(): ?string
  109. {
  110. return $this->description;
  111. }
  112. /**
  113. * @param string|null $description
  114. *
  115. * @return $this
  116. */
  117. public function setDescription(?string $description): self
  118. {
  119. $this->description = $description;
  120. return $this;
  121. }
  122. /**
  123. * @return DateTimeInterface|null
  124. */
  125. public function getCreatedAt(): ?DateTimeInterface
  126. {
  127. return $this->created_at;
  128. }
  129. /**
  130. * @param DateTimeInterface|null $created_at
  131. *
  132. * @return $this
  133. */
  134. public function setCreatedAt(?DateTimeInterface $created_at): self
  135. {
  136. $this->created_at = $created_at;
  137. return $this;
  138. }
  139. /**
  140. * @return DateTimeInterface|null
  141. */
  142. public function getUpdatedAt(): ?DateTimeInterface
  143. {
  144. return $this->updated_at;
  145. }
  146. /**
  147. * @param DateTimeInterface|null $updated_at
  148. *
  149. * @return $this
  150. */
  151. public function setUpdatedAt(?DateTimeInterface $updated_at): self
  152. {
  153. $this->updated_at = $updated_at;
  154. return $this;
  155. }
  156. /**
  157. * @return Collection
  158. */
  159. public function getHymns(): Collection
  160. {
  161. return $this->hymns;
  162. }
  163. /**
  164. * @param Hymns $hymn
  165. *
  166. * @return $this
  167. */
  168. public function addHymn(Hymns $hymn): self
  169. {
  170. if (! $this->hymns->contains($hymn)) {
  171. $this->hymns[] = $hymn;
  172. $hymn->setType($this);
  173. }
  174. return $this;
  175. }
  176. /**
  177. * @param Hymns $hymn
  178. *
  179. * @return $this
  180. */
  181. public function removeHymn(Hymns $hymn): self
  182. {
  183. if ($this->hymns->contains($hymn)) {
  184. $this->hymns->removeElement($hymn);
  185. // set the owning side to null (unless already changed)
  186. if ($hymn->getType() === $this) {
  187. $hymn->setType(null);
  188. }
  189. }
  190. return $this;
  191. }
  192. /**
  193. * @return string
  194. */
  195. public function __toString()
  196. {
  197. return (string) $this->getTitle();
  198. }
  199. }