1: <?php
2: namespace TIC\TownBundle\Entity;
3:
4: use TIC\TownBundle\Repository\DepartementRepository as EntityRepo;
5: use TIC\TownBundle\Traits\InseeTnccable;
6:
7: use Doctrine\ORM\Mapping as ORM;
8: use Doctrine\Common\Collections\ArrayCollection;
9:
10: /**
11: * Département français.
12: * @ORM\Table(name="tic_town_departement", indexes={
13: * @ORM\Index(name="nom_idx", columns={"nom"}),
14: * })
15: * @ORM\Entity(repositoryClass=EntityRepo::class)
16: */
17: class Departement
18: {
19: use InseeTnccable;
20:
21:
22: // --------------------------------------------------------------------- Properties
23:
24: /**
25: * @ORM\Id
26: * @ORM\Column(type="string", length=3)
27: */
28: private $insee;
29:
30: /**
31: * @ORM\Column(type="string", length=5, nullable=true)
32: */
33: private $cheflieu;
34:
35: /**
36: * @ORM\Column(type="string", length=255)
37: */
38: private $nom_maj;
39:
40: /**
41: * @ORM\Column(type="string", length=255)
42: */
43: private $nom;
44:
45: /**
46: * @ORM\ManyToOne(targetEntity="Region", inversedBy="departements")
47: * @ORM\JoinColumn(referencedColumnName="insee")
48: */
49: private $region;
50:
51: /**
52: * @ORM\OneToMany(targetEntity="Commune", mappedBy="departement")
53: */
54: private $communes;
55:
56: /**
57: * @ORM\Column(type="boolean")
58: */
59: private $enabled;
60:
61: /**
62: * @ORM\Column(type="boolean")
63: */
64: private $outre_mer;
65:
66:
67: // --------------------------------------------------------------------- Custom methods
68:
69: public function __construct()
70: {
71: $this->communes = new ArrayCollection();
72: $this->enabled = true;
73: $this->outre_mer = false;
74: }
75:
76: public function __toString()
77: {
78: # return $this->getArtNom();
79: return $this->getNomArt();
80: }
81:
82:
83: // --------------------------------------------------------------------- Shortcut methods
84:
85:
86: // --------------------------------------------------------------------- Tweaked methods
87:
88:
89: // --------------------------------------------------------------------- Auto-generated
90:
91: public function getInsee(): ?string
92: {
93: return $this->insee;
94: }
95:
96: public function setInsee($insee)
97: {
98: $this->insee = $insee;
99:
100: return $this;
101: }
102:
103: public function getCheflieu(): ?string
104: {
105: return $this->cheflieu;
106: }
107:
108: public function setCheflieu(?string $cheflieu): self
109: {
110: $this->cheflieu = $cheflieu;
111:
112: return $this;
113: }
114:
115: public function getNomMaj(): ?string
116: {
117: return $this->nom_maj;
118: }
119:
120: public function setNomMaj(string $nom_maj): self
121: {
122: $this->nom_maj = $nom_maj;
123:
124: return $this;
125: }
126:
127: public function getNom(): ?string
128: {
129: return $this->nom;
130: }
131:
132: public function setNom(string $nom): self
133: {
134: $this->nom = $nom;
135:
136: return $this;
137: }
138:
139: public function getEnabled(): ?bool
140: {
141: return $this->enabled;
142: }
143:
144: public function setEnabled(bool $enabled): self
145: {
146: $this->enabled = $enabled;
147:
148: return $this;
149: }
150:
151: public function getOutreMer(): ?bool
152: {
153: return $this->outre_mer;
154: }
155:
156: public function setOutreMer(bool $outre_mer): self
157: {
158: $this->outre_mer = $outre_mer;
159:
160: return $this;
161: }
162:
163: public function getRegion(): ?Region
164: {
165: return $this->region;
166: }
167:
168: public function setRegion(?Region $region): self
169: {
170: $this->region = $region;
171:
172: return $this;
173: }
174:
175: public function getCommunes(): ArrayCollection
176: {
177: return $this->communes;
178: }
179:
180: public function addCommune(Commune $commune): self
181: {
182: if (!$this->communes->contains($commune)) {
183: $this->communes[] = $commune;
184: $commune->setDepartement($this);
185: }
186:
187: return $this;
188: }
189:
190: public function removeCommune(Commune $commune): self
191: {
192: if ($this->communes->contains($commune)) {
193: $this->communes->removeElement($commune);
194: // set the owning side to null (unless already changed)
195: if ($commune->getDepartement() === $this) {
196: $commune->setDepartement(null);
197: }
198: }
199:
200: return $this;
201: }
202: }
203: