Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

279 lines
6.6KB

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