src/App/Entity/ExtendedApplication/ExtendedApplication.php line 35

Open in your IDE?
  1. <?php
  2. namespace App\Entity\ExtendedApplication;
  3. use App\Entity\PlatformSite;
  4. use App\Entity\Profile\JobseekerProfile;
  5. use App\Entity\RecurrentJob;
  6. use App\Service\ConversionEventService;
  7. use App\Service\MailService;
  8. use App\Utility\DateTimeUtility;
  9. use App\Utility\ReflectionHelper;
  10. use DateTime;
  11. use Doctrine\Common\Collections\ArrayCollection;
  12. use Doctrine\Common\Collections\Collection;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Exception;
  15. use InvalidArgumentException;
  16. use JanusHercules\ApplicationAppointmentScheduling\Domain\Entity\ApplicationAppointmentScheduling;
  17. use JanusHercules\ExternallyIncomingApplications\Domain\Entity\ExternallyIncomingApplication;
  18. use JanusHercules\Shared\Infrastructure\Service\PhoneNumberFormationInfrastructureService;
  19. use Symfony\Component\Validator\Constraints as Assert;
  20. /**
  21. * @ORM\Entity()
  22. *
  23. * @ORM\Table(
  24. * name="extended_applications",
  25. * indexes={
  26. *
  27. * @ORM\Index(name="email_idx", columns={"email"}),
  28. * @ORM\Index(name="jobseeker_profiles_id_recurrent_jobs_id_x", columns={"jobseeker_profiles_id", "recurrent_jobs_id"})
  29. * }
  30. * )
  31. */
  32. class ExtendedApplication
  33. {
  34. /** @throws Exception */
  35. public function __construct()
  36. {
  37. $this->firstname = '';
  38. $this->lastname = '';
  39. $this->email = '';
  40. $this->phone = '';
  41. $this->jobseekerProfile = null;
  42. $this->applicationText = null;
  43. $this->extendedApplicationCvFiles = new ArrayCollection([]);
  44. $this->createdAt = DateTimeUtility::createDateTimeUtc();
  45. $this->recurrentJobSearchterm = '';
  46. $this->recurrentJobBusinessName = '';
  47. $this->recurrentJobCustomerInternalId = null;
  48. $this->recurrentJobZipcode = null;
  49. $this->createdViaPlatformSiteId = PlatformSite::PLATFORM_SITE_ID_JOBOO;
  50. $this->createdViaCampaignId = null;
  51. $this->isReadByJobofferer = false;
  52. $this->extendedApplicationQuestionAnswers = new ArrayCollection();
  53. $this->externallyIncomingApplication = null;
  54. $this->applicationAppointmentScheduling = null;
  55. }
  56. /**
  57. * @ORM\GeneratedValue(strategy="CUSTOM")
  58. *
  59. * @ORM\CustomIdGenerator(class="App\Utility\DatabaseIdGenerator")
  60. *
  61. * @ORM\Column(name="id", type="guid")
  62. *
  63. * @ORM\Id
  64. */
  65. private string $id;
  66. public function getId(): string
  67. {
  68. return $this->id;
  69. }
  70. /**
  71. * @ORM\ManyToOne(targetEntity="App\Entity\Profile\JobseekerProfile", cascade={"persist"})
  72. *
  73. * @ORM\JoinColumn(name="jobseeker_profiles_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  74. */
  75. private ?JobseekerProfile $jobseekerProfile;
  76. public function setJobseekerProfile(?JobseekerProfile $jobseekerProfile): void
  77. {
  78. $this->jobseekerProfile = $jobseekerProfile;
  79. }
  80. public function getJobseekerProfile(): ?JobseekerProfile
  81. {
  82. return $this->jobseekerProfile;
  83. }
  84. /**
  85. * @ORM\ManyToOne(targetEntity="App\Entity\RecurrentJob", cascade={"persist"}, inversedBy="extendedApplications")
  86. *
  87. * @ORM\JoinColumn(name="recurrent_jobs_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  88. */
  89. private ?RecurrentJob $recurrentJob;
  90. public function setRecurrentJob(RecurrentJob $recurrentJob): void
  91. {
  92. $this->recurrentJob = $recurrentJob;
  93. $this->recurrentJobBusinessName = $recurrentJob->getBusinessName();
  94. $this->recurrentJobSearchterm = $recurrentJob->getOccupationalFieldSearchtermForDisplay();
  95. $this->recurrentJobCustomerInternalId = $recurrentJob->getIntegratedExternalPartnerCustomer()?->getInternalId();
  96. $this->recurrentJobZipcode = $recurrentJob->getZipcode();
  97. }
  98. public function getRecurrentJob(): ?RecurrentJob
  99. {
  100. return $this->recurrentJob;
  101. }
  102. /**
  103. * @ORM\Column(name="firstname", type="string", length=255, nullable=false)
  104. *
  105. * @Assert\NotBlank()
  106. *
  107. * @Assert\Length(
  108. * min = 2,
  109. * max = 50,
  110. * )
  111. */
  112. private string $firstname;
  113. public function getFirstname(): string
  114. {
  115. return $this->firstname;
  116. }
  117. public function setFirstname(string $firstname): void
  118. {
  119. $this->firstname = $firstname;
  120. }
  121. /**
  122. * @ORM\Column(name="application_text", type="text", length=16384, nullable=true)
  123. */
  124. private ?string $applicationText;
  125. public function getApplicationText(): ?string
  126. {
  127. return $this->applicationText;
  128. }
  129. public function setApplicationText(?string $applicationText): void
  130. {
  131. $this->applicationText = $applicationText;
  132. }
  133. /**
  134. * @ORM\Column(name="lastname", type="string", length=255, nullable=false)
  135. *
  136. * @Assert\NotBlank()
  137. */
  138. private string $lastname;
  139. public function getLastname(): string
  140. {
  141. return $this->lastname;
  142. }
  143. public function setLastname(string $lastname): void
  144. {
  145. $this->lastname = $lastname;
  146. }
  147. /**
  148. * @ORM\Column(name="email", type="string", length=255, nullable=false)
  149. *
  150. * @Assert\Email(mode="strict")
  151. *
  152. * @Assert\NotBlank()
  153. */
  154. private string $email;
  155. public function getEmail(): string
  156. {
  157. return $this->email;
  158. }
  159. public function setEmail(string $email): void
  160. {
  161. if (!MailService::emailAddressIsValidForMailer($email)) {
  162. throw new InvalidArgumentException("E-mail '$email' is not valid.");
  163. }
  164. $this->email = $email;
  165. }
  166. /**
  167. * @ORM\Column(name="phone", type="string", length=255, nullable=true)
  168. */
  169. private ?string $phone;
  170. public function getPhone(): ?string
  171. {
  172. return $this->phone;
  173. }
  174. public function setPhone(?string $phone): void
  175. {
  176. if (!is_null($phone)) {
  177. $phone = trim($phone);
  178. } else {
  179. $this->phone = null;
  180. }
  181. if (is_null(PhoneNumberFormationInfrastructureService::formatPhonenumberE164($phone))) {
  182. throw new InvalidArgumentException("Phone number $phone is not valid.");
  183. }
  184. $this->phone = $phone;
  185. }
  186. /**
  187. * @ORM\Column(name="created_at", type="datetime", nullable=false)
  188. */
  189. private DateTime $createdAt;
  190. public function getCreatedAt(): DateTime
  191. {
  192. return $this->createdAt;
  193. }
  194. /**
  195. * @var ExtendedApplicationCvFile[]|Collection
  196. *
  197. * @ORM\OneToMany(targetEntity="\App\Entity\ExtendedApplication\ExtendedApplicationCvFile", mappedBy="extendedApplication", cascade={"persist", "remove"})
  198. */
  199. private Collection $extendedApplicationCvFiles;
  200. public function getPrimaryCvFile(): ?ExtendedApplicationCvFile
  201. {
  202. return $this->extendedApplicationCvFiles->get(0);
  203. }
  204. public function setPrimaryCvFile(ExtendedApplicationCvFile $file): void
  205. {
  206. $this->extendedApplicationCvFiles[0] = $file;
  207. }
  208. public function getSecondaryCvFile(): ?ExtendedApplicationCvFile
  209. {
  210. return $this->extendedApplicationCvFiles->get(1);
  211. }
  212. public function setSecondaryCvFile(ExtendedApplicationCvFile $file): void
  213. {
  214. $this->extendedApplicationCvFiles[1] = $file;
  215. }
  216. public function getTertiaryCvFile(): ?ExtendedApplicationCvFile
  217. {
  218. return $this->extendedApplicationCvFiles->get(2);
  219. }
  220. public function setTertiaryCvFile(ExtendedApplicationCvFile $file): void
  221. {
  222. $this->extendedApplicationCvFiles[2] = $file;
  223. }
  224. public function removePrimaryFile(): void
  225. {
  226. $this->extendedApplicationCvFiles->remove(0);
  227. }
  228. public function removeSecondaryFile(): void
  229. {
  230. $this->extendedApplicationCvFiles->remove(1);
  231. }
  232. public function removeTertiaryFile(): void
  233. {
  234. $this->extendedApplicationCvFiles->remove(2);
  235. }
  236. /**
  237. * @ORM\Column(name="recurrent_job_searchterm", type="string", length=255, nullable=false)
  238. */
  239. private string $recurrentJobSearchterm;
  240. /**
  241. * @ORM\Column(name="recurrent_job_business_name", type="string", length=255, nullable=false)
  242. */
  243. private string $recurrentJobBusinessName;
  244. /**
  245. * @ORM\Column(name="recurrent_job_customer_internal_id", type="string", length=255, nullable=true)
  246. */
  247. private ?string $recurrentJobCustomerInternalId;
  248. /**
  249. * @ORM\Column(name="recurrent_job_zipcode", type="string", length=255, nullable=true)
  250. */
  251. private ?string $recurrentJobZipcode;
  252. public function getRecurrentJobSearchterm(): string
  253. {
  254. return $this->recurrentJobSearchterm;
  255. }
  256. public function getRecurrentJobBusinessName(): string
  257. {
  258. return $this->recurrentJobBusinessName;
  259. }
  260. public function getRecurrentJobCustomerInternalId(): ?string
  261. {
  262. return $this->recurrentJobCustomerInternalId;
  263. }
  264. public function getRecurrentJobZipcode(): ?string
  265. {
  266. return $this->recurrentJobZipcode;
  267. }
  268. /**
  269. * @ORM\Column(name="created_via_platform_site_id", type="integer", nullable=true)
  270. */
  271. private ?int $createdViaPlatformSiteId;
  272. public function getCreatedViaPlatformSiteId(): ?int
  273. {
  274. return $this->createdViaPlatformSiteId;
  275. }
  276. /**
  277. * @throws Exception
  278. */
  279. public function setCreatedViaPlatformSiteId(?int $createdViaPlatformSiteId): void
  280. {
  281. if (!is_null($createdViaPlatformSiteId) && !ReflectionHelper::hasConstWithValue(PlatformSite::class, 'PLATFORM_', $createdViaPlatformSiteId)) {
  282. throw new Exception("Not a valid value for createdVia: '$createdViaPlatformSiteId'.");
  283. }
  284. $this->createdViaPlatformSiteId = $createdViaPlatformSiteId;
  285. }
  286. /**
  287. * @ORM\Column(name="created_via_campaign_id", type="integer", nullable=true)
  288. */
  289. private ?int $createdViaCampaignId;
  290. public function getCreatedViaCampaignId(): ?int
  291. {
  292. return $this->createdViaCampaignId;
  293. }
  294. /**
  295. * @throws Exception
  296. */
  297. public function setCreatedViaCampaignId(?int $createdViaCampaignId): void
  298. {
  299. if (!is_null($createdViaCampaignId) && !in_array($createdViaCampaignId, ConversionEventService::AVAILABLE_CAMPAIGN_IDS_FOR_INCOMING_TRAFFIC)) {
  300. throw new Exception("Not a valid value for createdVia: '$createdViaCampaignId'.");
  301. }
  302. $this->createdViaCampaignId = $createdViaCampaignId;
  303. }
  304. /**
  305. * @ORM\Column(name="is_read_by_jobofferer", type="boolean", nullable=false)
  306. */
  307. private bool $isReadByJobofferer;
  308. public function isReadByJobofferer(): bool
  309. {
  310. return $this->isReadByJobofferer;
  311. }
  312. public function setIsReadByJobofferer(bool $isReadByJobofferer): void
  313. {
  314. $this->isReadByJobofferer = $isReadByJobofferer;
  315. }
  316. /**
  317. * @ORM\OneToMany(targetEntity="JanusHercules\ExtendedApplicationQuestionnaire\Domain\Entity\ExtendedApplicationQuestionAnswer", mappedBy="extendedApplication", cascade={"persist", "remove"})
  318. */
  319. private Collection $extendedApplicationQuestionAnswers;
  320. public function getExtendedApplicationQuestionAnswers(): Collection
  321. {
  322. return $this->extendedApplicationQuestionAnswers;
  323. }
  324. public function setExtendedApplicationQuestionAnswers(Collection $answers): void
  325. {
  326. $this->extendedApplicationQuestionAnswers = $answers;
  327. }
  328. /**
  329. * @ORM\OneToOne(targetEntity="JanusHercules\ExternallyIncomingApplications\Domain\Entity\ExternallyIncomingApplication", cascade={"persist"})
  330. *
  331. * @ORM\JoinColumn(name="externally_incoming_applications_id", referencedColumnName="id", nullable=true, onDelete="SET NULL")
  332. */
  333. private ?ExternallyIncomingApplication $externallyIncomingApplication;
  334. public function getExternallyIncomingApplication(): ?ExternallyIncomingApplication
  335. {
  336. return $this->externallyIncomingApplication;
  337. }
  338. public function setExternallyIncomingApplication(?ExternallyIncomingApplication $externallyIncomingApplication): void
  339. {
  340. $this->externallyIncomingApplication = $externallyIncomingApplication;
  341. }
  342. /**
  343. * @ORM\OneToOne(targetEntity="JanusHercules\ApplicationAppointmentScheduling\Domain\Entity\ApplicationAppointmentScheduling", mappedBy="extendedApplication", cascade={"persist", "remove"})
  344. */
  345. private ?ApplicationAppointmentScheduling $applicationAppointmentScheduling;
  346. public function getApplicationAppointmentScheduling(): ?ApplicationAppointmentScheduling
  347. {
  348. return $this->applicationAppointmentScheduling;
  349. }
  350. }