You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

78 lines
1.7KB

  1. <?php
  2. namespace Lc\PietroBundle\Model;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7. * @ORM\MappedSuperclass()
  8. */
  9. abstract class Thematic implements ThematicInterface
  10. {
  11. /**
  12. * @ORM\Column(type="string", length=255)
  13. */
  14. private $name;
  15. /**
  16. * @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\SubthematicInterface", mappedBy="thematic", cascade={"persist", "remove"})
  17. */
  18. private $subthematic;
  19. public function __construct()
  20. {
  21. $this->subthematic = new ArrayCollection();
  22. }
  23. public function __toString()
  24. {
  25. return $this->name;
  26. }
  27. public function getName(): ?string
  28. {
  29. return $this->name;
  30. }
  31. public function setName(string $name): self
  32. {
  33. $this->name = $name;
  34. return $this;
  35. }
  36. /**
  37. * @return Collection|SubthematicInterface[]
  38. */
  39. public function getSubthematic(): Collection
  40. {
  41. return $this->subthematic;
  42. }
  43. public function addSubthematic(SubthematicInterface $subthematic): self
  44. {
  45. if (!$this->subthematic->contains($subthematic)) {
  46. $this->subthematic[] = $subthematic;
  47. $subthematic->setThematic($this);
  48. }
  49. return $this;
  50. }
  51. public function removeSubthematic(SubthematicInterface $subthematic): self
  52. {
  53. if ($this->subthematic->removeElement($subthematic)) {
  54. // set the owning side to null (unless already changed)
  55. if ($subthematic->getThematic() === $this) {
  56. $subthematic->setThematic(null);
  57. }
  58. }
  59. return $this;
  60. }
  61. }