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.

94 lines
2.1KB

  1. <?php
  2. namespace Lc\PietroBundle\Model\Territory;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Lc\PietroBundle\Model\IndividualData\IndividualDataInterface;
  7. use Lc\SovBundle\Doctrine\Extension\DevAliasInterface;
  8. use Lc\SovBundle\Doctrine\Extension\DevAliasTrait;
  9. /**
  10. * @ORM\MappedSuperclass()
  11. */
  12. abstract class Territory implements TerritoryInterface, DevAliasInterface
  13. {
  14. use DevAliasTrait;
  15. /**
  16. * @ORM\Column(type="string", length=255)
  17. */
  18. protected $name;
  19. /**
  20. * @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\IndividualData\IndividualDataInterface", mappedBy="territory")
  21. */
  22. protected $individualData;
  23. public function __construct()
  24. {
  25. $this->individualData = new ArrayCollection();
  26. }
  27. public function __toString()
  28. {
  29. return $this->name;
  30. }
  31. public function getName(): ?string
  32. {
  33. return $this->name;
  34. }
  35. public function setName(string $name): self
  36. {
  37. $this->name = $name;
  38. return $this;
  39. }
  40. public function getIndividualData(): ?Collection
  41. {
  42. return $this->individualData;
  43. }
  44. public function setIndividualData(?IndividualDataInterface $individualData): self
  45. {
  46. $this->individualData = $individualData;
  47. return $this;
  48. }
  49. /**
  50. * @return Collection|TerritoryInterface[]
  51. */
  52. public function getTerritory(): Collection
  53. {
  54. return $this->territory;
  55. }
  56. public function addTerritory(TerritoryInterface $territory): self
  57. {
  58. if (!$this->territory->contains($territory)) {
  59. $this->territory[] = $territory;
  60. $territory->setIndividualData($this);
  61. }
  62. return $this;
  63. }
  64. public function removeTerritory(TerritoryInterface $territory): self
  65. {
  66. if ($this->territory->removeElement($territory)) {
  67. // set the owning side to null (unless already changed)
  68. if ($territory->getIndividualData() === $this) {
  69. $territory->setIndividualData(null);
  70. }
  71. }
  72. return $this;
  73. }
  74. }