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.

93 lines
2.0KB

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