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.

95 lines
2.1KB

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