src/Entity/Program.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\ProgramRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use JMS\Serializer\Annotation as Serializer;
  9. use Gedmo\Mapping\Annotation as Gedmo;
  10. /**
  11. * @ORM\Entity(repositoryClass=ProgramRepository::class)
  12. * @Assert\Callback({"App\Validator\PeriodValidator", "validate"})
  13. * @Serializer\ExclusionPolicy("ALL")
  14. */
  15. class Program extends BaseEntity
  16. {
  17. /**
  18. * @ORM\Id
  19. * @ORM\GeneratedValue
  20. * @ORM\Column(type="integer")
  21. * @Serializer\Expose
  22. * @Serializer\Groups({"participation"})
  23. *
  24. */
  25. private $id;
  26. /**
  27. * @ORM\Column(type="string", length=255)
  28. * @Serializer\Expose
  29. * @Serializer\Groups({"participation"})
  30. */
  31. private $label;
  32. /**
  33. * @ORM\Column(type="text", nullable=true)
  34. */
  35. private $objective;
  36. /**
  37. * @ORM\Column(type="datetime")
  38. * @Serializer\Expose
  39. */
  40. private $startAt;
  41. /**
  42. * @ORM\Column(type="datetime")
  43. * @Serializer\Expose
  44. */
  45. private $endAt;
  46. /**
  47. * @ORM\Column(type="text", nullable=true)
  48. * @Serializer\Expose
  49. */
  50. private $content;
  51. /**
  52. * @ORM\OneToMany(targetEntity=SubsidiaryCompany::class, mappedBy="program", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  53. */
  54. private $subsidiaryCompanies;
  55. /**
  56. * @ORM\OneToMany(targetEntity=Job::class, mappedBy="program", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  57. */
  58. private $jobs;
  59. /**
  60. * @ORM\OneToMany(targetEntity=Office::class, mappedBy="program", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  61. */
  62. private $offices;
  63. /**
  64. * @ORM\OneToMany(targetEntity=Contract::class, mappedBy="program", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  65. */
  66. private $contracts;
  67. /**
  68. * @ORM\Column(type="boolean", nullable=true)
  69. */
  70. private $isAllJobs = true;
  71. /**
  72. * @ORM\Column(type="boolean", nullable=true)
  73. */
  74. private $isAllOffices = true;
  75. /**
  76. * @ORM\Column(type="boolean", nullable=true)
  77. */
  78. private $isAllContracts = true;
  79. /**
  80. * @ORM\Column(type="boolean", nullable=true)
  81. */
  82. private $isAllSubsidiaryCompanies = true;
  83. /**
  84. * @ORM\Column(type="boolean", nullable=true)
  85. */
  86. private $isPublished = false;
  87. /**
  88. * @ORM\OneToOne(targetEntity=ImageManager::class, cascade={"persist", "remove"})
  89. * @Serializer\Expose
  90. */
  91. private $cover;
  92. /**
  93. * @ORM\OneToMany(targetEntity=ProgramParticipation::class, mappedBy="program", cascade={"persist", "remove"})
  94. */
  95. private $programParticipations;
  96. /**
  97. * @ORM\ManyToMany(targetEntity=Module::class, inversedBy="programs")
  98. */
  99. private $modules;
  100. /**
  101. * @ORM\OneToMany(targetEntity=ModuleParticipation::class, mappedBy="program", cascade={"remove"}, fetch="EXTRA_LAZY")
  102. */
  103. private $moduleParticipations;
  104. /**
  105. * @ORM\OneToMany(targetEntity=ProgramCertificate::class, mappedBy="program", cascade={"persist", "remove"}, fetch="EXTRA_LAZY")
  106. */
  107. private $certificates;
  108. /**
  109. * @ORM\ManyToMany(targetEntity=User::class, inversedBy="programs")
  110. */
  111. private $users;
  112. /**
  113. * @ORM\OneToMany(targetEntity=UserProgramParticipation::class, mappedBy="program", cascade={"remove"}, fetch="EXTRA_LAZY")
  114. */
  115. private $userProgramParticipations;
  116. /**
  117. * @ORM\OneToMany(targetEntity=UserModuleParticipation::class, mappedBy="program", cascade={"remove"}, fetch="EXTRA_LAZY")
  118. */
  119. private $userModuleParticipations;
  120. /**
  121. * @ORM\Column(type="boolean", nullable=true)
  122. */
  123. private $startingNotificationSent = false;
  124. /**
  125. * @Gedmo\Slug(fields={"label"})
  126. * @ORM\Column(length=191)
  127. */
  128. private $slug;
  129. /**
  130. * @ORM\OneToMany(targetEntity=Target::class, mappedBy="program", fetch="EXTRA_LAZY")
  131. */
  132. private $targets;
  133. public function __construct()
  134. {
  135. $this->subsidiaryCompanies = new ArrayCollection();
  136. $this->jobs = new ArrayCollection();
  137. $this->offices = new ArrayCollection();
  138. $this->contracts = new ArrayCollection();
  139. $this->programParticipations = new ArrayCollection();
  140. $this->modules = new ArrayCollection();
  141. $this->moduleParticipations = new ArrayCollection();
  142. $this->certificates = new ArrayCollection();
  143. $this->users = new ArrayCollection();
  144. $this->userProgramParticipations = new ArrayCollection();
  145. $this->userModuleParticipations = new ArrayCollection();
  146. $this->targets = new ArrayCollection();
  147. }
  148. public function getId(): ?int
  149. {
  150. return $this->id;
  151. }
  152. public function getLabel(): ?string
  153. {
  154. return $this->label;
  155. }
  156. public function setLabel(string $label): self
  157. {
  158. $this->label = $label;
  159. return $this;
  160. }
  161. public function getObjective(): ?string
  162. {
  163. return $this->objective;
  164. }
  165. public function setObjective(?string $objective): self
  166. {
  167. $this->objective = $objective;
  168. return $this;
  169. }
  170. public function getStartAt(): ?\DateTimeInterface
  171. {
  172. return $this->startAt;
  173. }
  174. public function setStartAt(\DateTimeInterface $startAt): self
  175. {
  176. $this->startAt = $startAt;
  177. return $this;
  178. }
  179. public function getEndAt(): ?\DateTimeInterface
  180. {
  181. return $this->endAt;
  182. }
  183. public function setEndAt(\DateTimeInterface $endAt): self
  184. {
  185. $this->endAt = $endAt;
  186. return $this;
  187. }
  188. public function getContent(): ?string
  189. {
  190. return $this->content;
  191. }
  192. public function setContent(?string $content): self
  193. {
  194. $this->content = $content;
  195. return $this;
  196. }
  197. /**
  198. * @return Collection<int, SubsidiaryCompany>
  199. */
  200. public function getSubsidiaryCompanies(): Collection
  201. {
  202. return $this->subsidiaryCompanies;
  203. }
  204. public function addSubsidiaryCompany(SubsidiaryCompany $subsidiaryCompany): self
  205. {
  206. if (!$this->subsidiaryCompanies->contains($subsidiaryCompany)) {
  207. $this->subsidiaryCompanies[] = $subsidiaryCompany;
  208. $subsidiaryCompany->setProgram($this);
  209. }
  210. return $this;
  211. }
  212. public function removeSubsidiaryCompany(SubsidiaryCompany $subsidiaryCompany): self
  213. {
  214. if ($this->subsidiaryCompanies->removeElement($subsidiaryCompany)) {
  215. // set the owning side to null (unless already changed)
  216. if ($subsidiaryCompany->getProgram() === $this) {
  217. $subsidiaryCompany->setProgram(null);
  218. }
  219. }
  220. return $this;
  221. }
  222. /**
  223. * @return Collection<int, Job>
  224. */
  225. public function getJobs(): Collection
  226. {
  227. return $this->jobs;
  228. }
  229. public function addJob(Job $job): self
  230. {
  231. if (!$this->jobs->contains($job)) {
  232. $this->jobs[] = $job;
  233. $job->setProgram($this);
  234. }
  235. return $this;
  236. }
  237. public function removeJob(Job $job): self
  238. {
  239. if ($this->jobs->removeElement($job)) {
  240. // set the owning side to null (unless already changed)
  241. if ($job->getProgram() === $this) {
  242. $job->setProgram(null);
  243. }
  244. }
  245. return $this;
  246. }
  247. /**
  248. * @return Collection<int, Office>
  249. */
  250. public function getOffices(): Collection
  251. {
  252. return $this->offices;
  253. }
  254. public function addOffice(Office $office): self
  255. {
  256. if (!$this->offices->contains($office)) {
  257. $this->offices[] = $office;
  258. $office->setProgram($this);
  259. }
  260. return $this;
  261. }
  262. public function removeOffice(Office $office): self
  263. {
  264. if ($this->offices->removeElement($office)) {
  265. // set the owning side to null (unless already changed)
  266. if ($office->getProgram() === $this) {
  267. $office->setProgram(null);
  268. }
  269. }
  270. return $this;
  271. }
  272. /**
  273. * @return Collection<int, Contract>
  274. */
  275. public function getContracts(): Collection
  276. {
  277. return $this->contracts;
  278. }
  279. public function addContract(Contract $contract): self
  280. {
  281. if (!$this->contracts->contains($contract)) {
  282. $this->contracts[] = $contract;
  283. $contract->setProgram($this);
  284. }
  285. return $this;
  286. }
  287. public function removeContract(Contract $contract): self
  288. {
  289. if ($this->contracts->removeElement($contract)) {
  290. // set the owning side to null (unless already changed)
  291. if ($contract->getProgram() === $this) {
  292. $contract->setProgram(null);
  293. }
  294. }
  295. return $this;
  296. }
  297. public function isIsAllJobs(): ?bool
  298. {
  299. return $this->isAllJobs;
  300. }
  301. public function setIsAllJobs(?bool $isAllJobs): self
  302. {
  303. $this->isAllJobs = $isAllJobs;
  304. return $this;
  305. }
  306. public function isIsAllOffices(): ?bool
  307. {
  308. return $this->isAllOffices;
  309. }
  310. public function setIsAllOffices(?bool $isAllOffices): self
  311. {
  312. $this->isAllOffices = $isAllOffices;
  313. return $this;
  314. }
  315. public function isIsAllContracts(): ?bool
  316. {
  317. return $this->isAllContracts;
  318. }
  319. public function setIsAllContracts(?bool $isAllContracts): self
  320. {
  321. $this->isAllContracts = $isAllContracts;
  322. return $this;
  323. }
  324. public function isIsAllSubsidiaryCompanies(): ?bool
  325. {
  326. return $this->isAllSubsidiaryCompanies;
  327. }
  328. public function setIsAllSubsidiaryCompanies(?bool $isAllSubsidiaryCompanies): self
  329. {
  330. $this->isAllSubsidiaryCompanies = $isAllSubsidiaryCompanies;
  331. return $this;
  332. }
  333. public function isIsPublished(): ?bool
  334. {
  335. return $this->isPublished;
  336. }
  337. public function setIsPublished(?bool $isPublished): self
  338. {
  339. $this->isPublished = $isPublished;
  340. return $this;
  341. }
  342. public function getCover(): ?ImageManager
  343. {
  344. return $this->cover;
  345. }
  346. public function setCover(?ImageManager $cover): self
  347. {
  348. $this->cover = $cover;
  349. return $this;
  350. }
  351. /**
  352. * @return Collection<int, ProgramParticipation>
  353. */
  354. public function getProgramParticipations(): Collection
  355. {
  356. return $this->programParticipations;
  357. }
  358. public function addProgramParticipation(ProgramParticipation $programParticipation): self
  359. {
  360. if (!$this->programParticipations->contains($programParticipation)) {
  361. $this->programParticipations[] = $programParticipation;
  362. $programParticipation->setProgram($this);
  363. }
  364. return $this;
  365. }
  366. public function removeProgramParticipation(ProgramParticipation $programParticipation): self
  367. {
  368. if ($this->programParticipations->removeElement($programParticipation)) {
  369. // set the owning side to null (unless already changed)
  370. if ($programParticipation->getProgram() === $this) {
  371. $programParticipation->setProgram(null);
  372. }
  373. }
  374. return $this;
  375. }
  376. /**
  377. * @return Collection<int, Module>
  378. */
  379. public function getModules(): Collection
  380. {
  381. return $this->modules;
  382. }
  383. public function addModule(Module $module): self
  384. {
  385. if (!$this->modules->contains($module)) {
  386. $this->modules[] = $module;
  387. }
  388. return $this;
  389. }
  390. public function removeModule(Module $module): self
  391. {
  392. $this->modules->removeElement($module);
  393. return $this;
  394. }
  395. /**
  396. * @return Collection<int, ModuleParticipation>
  397. */
  398. public function getModuleParticipations(): Collection
  399. {
  400. return $this->moduleParticipations;
  401. }
  402. public function addModuleParticipation(ModuleParticipation $moduleParticipation): self
  403. {
  404. if (!$this->moduleParticipations->contains($moduleParticipation)) {
  405. $this->moduleParticipations[] = $moduleParticipation;
  406. $moduleParticipation->setProgram($this);
  407. }
  408. return $this;
  409. }
  410. public function removeModuleParticipation(ModuleParticipation $moduleParticipation): self
  411. {
  412. if ($this->moduleParticipations->removeElement($moduleParticipation)) {
  413. // set the owning side to null (unless already changed)
  414. if ($moduleParticipation->getProgram() === $this) {
  415. $moduleParticipation->setProgram(null);
  416. }
  417. }
  418. return $this;
  419. }
  420. /**
  421. * @return Collection<int, ProgramCertificate>
  422. */
  423. public function getCertificates(): Collection
  424. {
  425. return $this->certificates;
  426. }
  427. public function addCertificate(ProgramCertificate $certificate): self
  428. {
  429. if (!$this->certificates->contains($certificate)) {
  430. $this->certificates[] = $certificate;
  431. $certificate->setProgram($this);
  432. }
  433. return $this;
  434. }
  435. public function removeCertificate(ProgramCertificate $certificate): self
  436. {
  437. if ($this->certificates->removeElement($certificate)) {
  438. // set the owning side to null (unless already changed)
  439. if ($certificate->getProgram() === $this) {
  440. $certificate->setProgram(null);
  441. }
  442. }
  443. return $this;
  444. }
  445. /**
  446. * @return Collection<int, User>
  447. */
  448. public function getUsers(): Collection
  449. {
  450. return $this->users;
  451. }
  452. public function addUser(User $user): self
  453. {
  454. if (!$this->users->contains($user)) {
  455. $this->users[] = $user;
  456. }
  457. return $this;
  458. }
  459. public function removeUser(User $user): self
  460. {
  461. $this->users->removeElement($user);
  462. return $this;
  463. }
  464. /**
  465. * @return Collection<int, UserProgramParticipation>
  466. */
  467. public function getUserProgramParticipations(): Collection
  468. {
  469. return $this->userProgramParticipations;
  470. }
  471. public function addUserProgramParticipation(UserProgramParticipation $userProgramParticipation): self
  472. {
  473. if (!$this->userProgramParticipations->contains($userProgramParticipation)) {
  474. $this->userProgramParticipations[] = $userProgramParticipation;
  475. $userProgramParticipation->setProgram($this);
  476. }
  477. return $this;
  478. }
  479. public function removeUserProgramParticipation(UserProgramParticipation $userProgramParticipation): self
  480. {
  481. if ($this->userProgramParticipations->removeElement($userProgramParticipation)) {
  482. // set the owning side to null (unless already changed)
  483. if ($userProgramParticipation->getProgram() === $this) {
  484. $userProgramParticipation->setProgram(null);
  485. }
  486. }
  487. return $this;
  488. }
  489. /**
  490. * @return Collection<int, UserModuleParticipation>
  491. */
  492. public function getUserModuleParticipations(): Collection
  493. {
  494. return $this->userModuleParticipations;
  495. }
  496. public function addUserModuleParticipation(UserModuleParticipation $userModuleParticipation): self
  497. {
  498. if (!$this->userModuleParticipations->contains($userModuleParticipation)) {
  499. $this->userModuleParticipations[] = $userModuleParticipation;
  500. $userModuleParticipation->setProgram($this);
  501. }
  502. return $this;
  503. }
  504. public function removeUserModuleParticipation(UserModuleParticipation $userModuleParticipation): self
  505. {
  506. if ($this->userModuleParticipations->removeElement($userModuleParticipation)) {
  507. // set the owning side to null (unless already changed)
  508. if ($userModuleParticipation->getProgram() === $this) {
  509. $userModuleParticipation->setProgram(null);
  510. }
  511. }
  512. return $this;
  513. }
  514. public function isStartingNotificationSent(): ?bool
  515. {
  516. return $this->startingNotificationSent;
  517. }
  518. public function setStartingNotificationSent(?bool $startingNotificationSent): self
  519. {
  520. $this->startingNotificationSent = $startingNotificationSent;
  521. return $this;
  522. }
  523. /**
  524. * Get the value of slug
  525. */
  526. public function getSlug()
  527. {
  528. return $this->slug;
  529. }
  530. /**
  531. * Set the value of slug
  532. *
  533. * @return self
  534. */
  535. public function setSlug($slug)
  536. {
  537. $this->slug = $slug;
  538. return $this;
  539. }
  540. /**
  541. * @return Collection<int, Target>
  542. */
  543. public function getTarges(): Collection
  544. {
  545. return $this->targets;
  546. }
  547. public function addTarget(Target $target): self
  548. {
  549. if (!$this->targets->contains($target)) {
  550. $this->targets[] = $target;
  551. $target->setProgram($this);
  552. }
  553. return $this;
  554. }
  555. public function removeTarget(Target $target): self
  556. {
  557. if ($this->targets->removeElement($target)) {
  558. // set the owning side to null (unless already changed)
  559. if ($target->getProgram() === $this) {
  560. $target->setProgram(null);
  561. }
  562. }
  563. return $this;
  564. }
  565. }