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.

Territory.php 2.2KB

3 lat temu
3 lat temu
3 lat temu
3 lat temu
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  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\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 TerritoryInterface, DevAliasInterface, EntityInterface
  14. {
  15. use DevAliasTrait;
  16. /**
  17. * @ORM\Column(type="string", length=255)
  18. */
  19. protected $name;
  20. /**
  21. * @ORM\OneToMany(targetEntity="Lc\PietroBundle\Model\IndividualData\IndividualDataInterface", mappedBy="territory")
  22. */
  23. protected $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(?IndividualDataInterface $individualData): self
  46. {
  47. $this->individualData = $individualData;
  48. return $this;
  49. }
  50. /**
  51. * @return Collection|TerritoryInterface[]
  52. */
  53. public function getTerritory(): Collection
  54. {
  55. return $this->territory;
  56. }
  57. public function addTerritory(TerritoryInterface $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(TerritoryInterface $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. }