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.

262 lines
6.3KB

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