Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

282 lines
6.7KB

  1. <?php
  2. namespace App\Entity\CollectifData;
  3. use App\Entity\Dream\Dream;
  4. use App\Entity\ProjectBoost\ProjectBoost;
  5. use App\Entity\ProjectInspiring\ProjectInspiring;
  6. use App\Entity\Revolt\Revolt;
  7. use App\Entity\Territory\Territory;
  8. use App\Entity\User\User;
  9. use App\Repository\CollectifData\CollectifDataRepository;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Lc\PietroBundle\Model\AbstractData as PietroAbstractData;
  14. /**
  15. * @ORM\Entity(repositoryClass=CollectifDataRepository::class)
  16. */
  17. class CollectifData extends PietroAbstractData
  18. {
  19. /**
  20. * @ORM\Id
  21. * @ORM\GeneratedValue
  22. * @ORM\Column(type="integer")
  23. */
  24. private $id;
  25. /**
  26. * @ORM\Column(type="string", length=255, nullable=true)
  27. */
  28. private $name;
  29. /**
  30. * @ORM\ManyToOne(targetEntity=User::class, inversedBy="collectifData")
  31. */
  32. private $user;
  33. /**
  34. * @ORM\Column(type="integer")
  35. */
  36. private $nbParticipant;
  37. /**
  38. * @ORM\OneToMany(targetEntity=Revolt::class, mappedBy="collectifData", cascade={"persist", "remove"})
  39. */
  40. protected $revolt;
  41. /**
  42. * @ORM\OneToMany(targetEntity=Dream::class, mappedBy="collectifData", cascade={"persist", "remove"})
  43. */
  44. protected $dream;
  45. /**
  46. * @ORM\OneToMany(targetEntity=ProjectBoost::class, mappedBy="collectifData", cascade={"persist", "remove"})
  47. */
  48. protected $projectBoost;
  49. /**
  50. * @ORM\OneToMany(targetEntity=ProjectInspiring::class, mappedBy="collectifData", cascade={"persist", "remove"})
  51. */
  52. protected $projectInspiring;
  53. /**
  54. * @ORM\ManyToOne(targetEntity=Territory::class, inversedBy="collectifData")
  55. */
  56. protected $territory;
  57. public function __construct()
  58. {
  59. $this->revolt = new ArrayCollection();
  60. $this->dream = new ArrayCollection();
  61. $this->projectBoost = new ArrayCollection();
  62. $this->projectInspiring = new ArrayCollection();
  63. }
  64. public function __toString()
  65. {
  66. return $this->nbParticipant . " participants";
  67. }
  68. public function getResume()
  69. {
  70. return count($this->getRevolt()) . " révolte(s) - " . count($this->getDream()) . " rêve(s) - " . count(
  71. $this->getProjectBoost()
  72. ) . " projet(s) boosté(s) - " . count($this->getProjectInspiring()) . " projets inspirants";
  73. }
  74. public function getNbDream(): string
  75. {
  76. return count($this->getDream());
  77. }
  78. public function getNbRevolt(): string
  79. {
  80. return count($this->getRevolt());
  81. }
  82. public function getNbProjectBoost(): string
  83. {
  84. return count($this->getProjectBoost());
  85. }
  86. public function getNbProjectInspiring(): string
  87. {
  88. return count($this->getProjectInspiring());
  89. }
  90. public function getId(): ?int
  91. {
  92. return $this->id;
  93. }
  94. public function getName(): ?string
  95. {
  96. return $this->name;
  97. }
  98. public function setName(string $name): self
  99. {
  100. $this->name = $name;
  101. return $this;
  102. }
  103. public function getUser(): ?User
  104. {
  105. return $this->user;
  106. }
  107. public function setUser(?User $user): self
  108. {
  109. $this->user = $user;
  110. return $this;
  111. }
  112. public function getNbParticipant(): ?int
  113. {
  114. return $this->nbParticipant;
  115. }
  116. public function setNbParticipant(int $nbParticipant): self
  117. {
  118. $this->nbParticipant = $nbParticipant;
  119. return $this;
  120. }
  121. /**
  122. * @return Collection|Revolt[]
  123. */
  124. public function getRevolt(): Collection
  125. {
  126. return $this->revolt;
  127. }
  128. public function addRevolt(Revolt $revolt): self
  129. {
  130. if (!$this->revolt->contains($revolt)) {
  131. $this->revolt[] = $revolt;
  132. $revolt->setCollectifData($this);
  133. }
  134. return $this;
  135. }
  136. public function removeRevolt(Revolt $revolt): self
  137. {
  138. if ($this->revolt->removeElement($revolt)) {
  139. // set the owning side to null (unless already changed)
  140. if ($revolt->getCollectifData() === $this) {
  141. $revolt->setCollectifData(null);
  142. }
  143. }
  144. return $this;
  145. }
  146. /**
  147. * @return Collection|Dream[]
  148. */
  149. public function getDream(): Collection
  150. {
  151. return $this->dream;
  152. }
  153. public function addDream(Dream $dream): self
  154. {
  155. if (!$this->dream->contains($dream)) {
  156. $this->dream[] = $dream;
  157. $dream->setCollectifData($this);
  158. }
  159. return $this;
  160. }
  161. public function removeDream(Dream $dream): self
  162. {
  163. if ($this->dream->removeElement($dream)) {
  164. // set the owning side to null (unless already changed)
  165. if ($dream->getCollectifData() === $this) {
  166. $dream->setCollectifData(null);
  167. }
  168. }
  169. return $this;
  170. }
  171. /**
  172. * @return Collection|ProjectBoost[]
  173. */
  174. public function getProjectBoost(): Collection
  175. {
  176. return $this->projectBoost;
  177. }
  178. public function addProjectBoost(ProjectBoost $projectBoost): self
  179. {
  180. if (!$this->projectBoost->contains($projectBoost)) {
  181. $this->projectBoost[] = $projectBoost;
  182. $projectBoost->setCollectifData($this);
  183. }
  184. return $this;
  185. }
  186. public function removeProjectBoost(ProjectBoost $projectBoost): self
  187. {
  188. if ($this->projectBoost->removeElement($projectBoost)) {
  189. // set the owning side to null (unless already changed)
  190. if ($projectBoost->getCollectifData() === $this) {
  191. $projectBoost->setCollectifData(null);
  192. }
  193. }
  194. return $this;
  195. }
  196. /**
  197. * @return Collection|ProjectInspiring[]
  198. */
  199. public function getProjectInspiring(): Collection
  200. {
  201. return $this->projectInspiring;
  202. }
  203. public function addProjectInspiring(ProjectInspiring $projectInspiring): self
  204. {
  205. if (!$this->projectInspiring->contains($projectInspiring)) {
  206. $this->projectInspiring[] = $projectInspiring;
  207. $projectInspiring->setCollectifData($this);
  208. }
  209. return $this;
  210. }
  211. public function removeProjectInspiring(ProjectInspiring $projectInspiring): self
  212. {
  213. if ($this->projectInspiring->removeElement($projectInspiring)) {
  214. // set the owning side to null (unless already changed)
  215. if ($projectInspiring->getCollectifData() === $this) {
  216. $projectInspiring->setCollectifData(null);
  217. }
  218. }
  219. return $this;
  220. }
  221. public function getTerritory(): ?Territory
  222. {
  223. return $this->territory;
  224. }
  225. public function setTerritory(?Territory $territory): self
  226. {
  227. $this->territory = $territory;
  228. return $this;
  229. }
  230. }