Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

80 lines
1.8KB

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