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.

79 lines
1.7KB

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