<?php
namespace App\Entity;
use App\Annotations\Xss\XssAware;
use App\Annotations\Xss\XssProperty;
use App\Component\GDPR\Annotation as GDPR;
use App\Component\GDPR\Entity\AnonymizedTrait;
use App\Validator as SerenaAssert;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Gedmo\Mapping\Annotation as Gedmo;
use JMS\Serializer\Annotation as JMS;
use Symfony\Component\HttpFoundation\File\File;
use Symfony\Component\HttpFoundation\File\UploadedFile;
use Symfony\Component\Validator\Constraints as Assert;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
/**
* Vacancy.
*
* @ORM\Table(name="applicant")
* @ORM\Entity(repositoryClass="App\Entity\Repository\ApplicantRepository")
* @Vich\Uploadable
* @JMS\ExclusionPolicy("all")
* @Gedmo\SoftDeleteable(fieldName="deletedAt")
* @XssAware
* @SerenaAssert\UniqueApplication()
*/
class Applicant
{
use AnonymizedTrait;
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
* @JMS\Expose()
*/
private $id;
/**
* Many Applicants have One Vacancy.
*
* @var Vacancy
*
* @ORM\ManyToOne(targetEntity="Vacancy", inversedBy="applicants", fetch="EAGER")
*/
private $vacancy;
/**
* @var string
*
* @ORM\Column(name="first_name", type="string", length=170, nullable=true)
* @JMS\Expose()
* @JMS\SerializedName("firstname")
* @GDPR\Anonymize(type="fixed", value="anonymized")
* @XssProperty
*/
private $firstName;
/**
* @var string|null
*
* @ORM\Column(name="insertion", type="string", nullable=true)
* @GDPR\Anonymize(type="null")
* @XssProperty
*/
private $insertion;
/**
* @var string
*
* @ORM\Column(name="last_name", type="string", length=170, nullable=true)
* @JMS\Expose()
* @JMS\SerializedName("lastname")
* @GDPR\Anonymize(type="fixed", value="anonymized")
* @XssProperty
*/
private $lastName;
/**
* @var string|null
*
* @ORM\Column(name="city", type="string", length=170, nullable=true)
* @JMS\Expose()
* @GDPR\Anonymize(type="fixed", value="anonymized")
* @XssProperty
*/
private $city;
/**
* @var PhoneNumber|null
* @ORM\Column(name="phone", type="phone_number", nullable=true)
*
* @JMS\Expose()
* @JMS\Type("App\Entity\PhoneNumber")
*
* @GDPR\Anonymize(type="null")
*/
private $phone;
/**
* @var PhoneNumber|null
* @ORM\Column(name="intl_phone", type="phone_number", nullable=true)
*
* @JMS\SerializedName("intlphone")
* @JMS\Type("App\Entity\PhoneNumber")
*
* @GDPR\Anonymize(type="null")
*/
private $intlPhone;
/**
* @var string
*
* @ORM\Column(name="email", type="string", length=170, nullable=true)
* @JMS\Expose()
* @GDPR\Anonymize(type="hash")
*/
#[Assert\Email]
private $email;
/**
* @ORM\Column(type="datetime")
*
* @var \DateTime
*/
private $createdAt;
/**
* @Vich\UploadableField(mapping="applicant_upload", fileNameProperty="fileName", size="fileSize")
*
* @var File
* @GDPR\Anonymize(type="null")
*/
private $CVFile;
/**
* @Vich\UploadableField(mapping="applicant_upload", fileNameProperty="fileNameMotivation", size="fileSizeMotivation")
*
* @var File
* @GDPR\Anonymize(type="null")
*/
private $motivationFile;
/**
* @ORM\Column(type="string", length=170, nullable=true)
*
* @var string
* @GDPR\Anonymize(type="null")
*/
private $fileName;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var int
*/
private $fileSize;
/**
* @ORM\Column(type="string", length=170, nullable=true)
*
* @var string
* @GDPR\Anonymize(type="null")
*/
private $fileNameMotivation;
/**
* @ORM\Column(type="integer", nullable=true)
*
* @var int
*/
private $fileSizeMotivation;
/**
* @var string
*
* @ORM\Column(name="motivation", type="text", nullable=true)
* @JMS\Expose()
* @GDPR\Anonymize(type="fixed", value="anonymized")
* @XssProperty
*/
private $motivation;
/**
* Many applicants have one Status.
*
* @var Status
*
* @ORM\ManyToOne(targetEntity="App\Entity\Status")
*/
private $status;
/**
* @var string
*
* @ORM\Column(name="description", type="text", nullable=true)
* @XssProperty
*/
private $description;
/**
* One Applicant has Many Notes.
*
* @var Note[]|ArrayCollection
*
* @ORM\OneToMany(targetEntity="Note", mappedBy="applicant", cascade={"persist",
* "remove"}, orphanRemoval=true)
* @ORM\OrderBy({"createdAt": "DESC"})
*/
private $notes;
/**
* @var string This is saved as json
*
* @ORM\Column(type="text", nullable=true)
* @GDPR\Anonymize(type="null")
*/
private $data;
/**
* @var string
*
* @ORM\Column(type="text", nullable=true)
*/
private $questionAnswerData;
/**
* @var bool
*
* @ORM\Column(type="boolean", name="privacy_policy")
*/
private $acceptedPrivacyPolicy = false;
/**
* @var bool
*
* @ORM\Column(type="boolean", name="applicant_send_to_applicant_mail")
*/
private $applicantSendToApplicantMail = false;
/**
* @var string
*
* @ORM\Column(type="string", name="linkedin_profile_url", nullable=true)
* @XssProperty
*/
private $linkedinProfileUrl;
/**
* @var DateTime
*
* @ORM\Column(name="deleted_at", type="datetime", nullable=true)
*/
private $deletedAt;
/**
* @var bool
*
* @ORM\Column(type="boolean", name="clone")
*/
private $clone = false;
/**
* @var bool
*
* @ORM\Column(type="boolean", name="manual")
*/
private $manual = false;
/**
* Many Triggers have One Mail.
*
* @var Mail|null
*
* @ORM\ManyToOne(targetEntity="Mail")
*/
private $manualMail;
/**
* @ORM\Column(type="datetime", name="sent_at", nullable=true)
*
* @var DateTime
*/
private $sentAt;
/**
* @var string|null
*
* @ORM\Column(type="string", name="external_id", nullable=true)
*/
private $externalId;
/**
* @var string|null
*
* External ID for the Candidate object
*
* @ORM\Column(type="string", nullable=true)
*/
private $externalCandidateId;
/**
* @var DateTime
*
* @ORM\Column(type="datetime", nullable=true)
* @Gedmo\Timestampable(on="update")
*/
private $updatedAt;
/**
* @var array
*
* @ORM\Column(type="array", nullable=true)
*/
private $utm;
/**
* @var string
*
* @ORM\Column(name="knockout_question_answers", type="json", nullable=true)
*/
private $knockoutQuestionAnswers;
/**
* @var bool
*
* @ORM\Column(type="boolean", name="rejected_by_knockout")
*/
private $rejectedByKnockout = false;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\GdprStatement")
*
* @var GdprStatement
*/
private $gdpr;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $locale;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $externalResumeId;
/**
* URL from where the applicant has applied.
*
* @ORM\Column(type="string", length=255, nullable=true)
*/
private ?string $applyUrl = null;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Company")
*/
private ?Company $company = null;
/** @ORM\ManyToOne(targetEntity="App\Entity\ApplicantForm", inversedBy="applicants") */
private ?ApplicantForm $applicantForm = null;
public function __construct()
{
$this->utm = [];
if (null === $this->getCreatedAt()) {
$this->setCreatedAt(new \DateTime('now'));
}
$this->notes = new ArrayCollection();
}
public function getFirstName(): ?string
{
return $this->firstName;
}
public function setFirstName(?string $firstName): self
{
$this->firstName = $firstName;
return $this;
}
public function getInsertion(): ?string
{
return $this->insertion;
}
public function setInsertion(?string $insertion): self
{
$this->insertion = $insertion;
return $this;
}
public function getLastName(): ?string
{
return $this->lastName;
}
public function setLastName(?string $lastName): self
{
$this->lastName = $lastName;
return $this;
}
public function getFullName(): string
{
$arguments = [
$this->firstName,
$this->insertion,
$this->lastName,
];
return implode(' ', array_filter($arguments));
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(?string $city): self
{
$this->city = $city;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|UploadedFile $cv
*/
public function setCVFile(File $cv = null): self
{
$this->CVFile = $cv;
if (null !== $cv) {
$this->updatedAt = new \DateTimeImmutable();
}
return $this;
}
/**
* @return File
*/
public function getCVFile()
{
return $this->CVFile;
}
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|UploadedFile $cv
*/
public function setMotivationFile(File $motivationFile = null): self
{
$this->motivationFile = $motivationFile;
if (null !== $motivationFile) {
$this->updatedAt = new \DateTimeImmutable();
}
return $this;
}
/**
* @return File
*/
public function getMotivationFile(): ?File
{
return $this->motivationFile;
}
public function setFileName(?string $fileName): self
{
$this->fileName = $fileName;
return $this;
}
public function getFileName(): ?string
{
return $this->fileName;
}
public function setFileSize(?int $fileSize): self
{
$this->fileSize = $fileSize;
return $this;
}
public function getFileSize(): ?int
{
return $this->fileSize;
}
public function setFileNameMotivation(?string $fileNameMotivation): self
{
$this->fileNameMotivation = $fileNameMotivation;
return $this;
}
public function getFileNameMotivation(): ?string
{
return $this->fileNameMotivation;
}
public function setFileSizeMotivation(?int $fileSizeMotivation): self
{
$this->fileSizeMotivation = $fileSizeMotivation;
return $this;
}
public function getFileSizeMotivation(): ?int
{
return $this->fileSizeMotivation;
}
public function getId(): ?int
{
return $this->id;
}
public function getMotivation(): ?string
{
return $this->motivation;
}
public function setMotivation(?string $motivation): self
{
$this->motivation = $motivation;
return $this;
}
public function getStatus(): ?Status
{
return $this->status;
}
public function setStatus(?Status $status): self
{
$this->status = $status;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): self
{
$this->description = $description;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(?string $email): self
{
$this->email = null !== $email ? mb_strtolower($email) : null;
return $this;
}
public function getVacancy(): ?Vacancy
{
return $this->vacancy;
}
public function setVacancy(?Vacancy $vacancy): self
{
$this->vacancy = $vacancy;
return $this;
}
public function getPhone(): ?PhoneNumber
{
return $this->phone;
}
public function setPhone(?PhoneNumber $phone): self
{
$this->phone = $phone;
return $this;
}
public function getIntlPhone(): ?PhoneNumber
{
return $this->intlPhone;
}
public function setIntlPhone(?PhoneNumber $intlPhone): self
{
$this->intlPhone = $intlPhone;
return $this;
}
public function getData(): ?string
{
return $this->data;
}
/**
* Get the applicant data as array instead of JSON.
*/
public function getDataArray(): ?array
{
return json_decode($this->data, true);
}
public function setData(?string $data): self
{
$this->data = $data;
return $this;
}
public function getQuestionAnswerData(): ?string
{
return $this->questionAnswerData;
}
public function setQuestionAnswerData(?string $questionAnswerData): self
{
$this->questionAnswerData = $questionAnswerData;
return $this;
}
/**
* @return Collection|Note[]
*/
public function getNotes(): Collection
{
return $this->notes;
}
public function addNote(Note $note): self
{
if (!$this->notes->contains($note)) {
$this->notes[] = $note;
$note->setApplicant($this);
}
return $this;
}
/**
* @return $this
*/
public function removeValue(Note $note)
{
$this->notes->removeElement($note);
return $this;
}
public function hasAcceptedPrivacyPolicy(): bool
{
return $this->acceptedPrivacyPolicy;
}
public function setAcceptedPrivacyPolicy(bool $acceptedPrivacyPolicy): self
{
$this->acceptedPrivacyPolicy = $acceptedPrivacyPolicy;
return $this;
}
public function isApplicantSendToApplicantMail(): bool
{
return $this->applicantSendToApplicantMail;
}
public function setApplicantSendToApplicantMail(bool $applicantSendToApplicantMail): self
{
$this->applicantSendToApplicantMail = $applicantSendToApplicantMail;
return $this;
}
public function getLinkedinProfileUrl(): ?string
{
return $this->linkedinProfileUrl;
}
public function setLinkedinProfileUrl(?string $linkedinProfileUrl): self
{
$this->linkedinProfileUrl = $linkedinProfileUrl;
return $this;
}
public function getDeletedAt(): ?\DateTimeInterface
{
return $this->deletedAt;
}
public function setDeletedAt(?\DateTimeInterface $deletedAt): self
{
$this->deletedAt = $deletedAt;
return $this;
}
public function isClone(): bool
{
return $this->clone;
}
public function setClone(bool $clone): self
{
$this->clone = $clone;
return $this;
}
public function isManual(): bool
{
return $this->manual;
}
public function setManual(bool $manual): self
{
$this->manual = $manual;
return $this;
}
public function getManualMail(): ?Mail
{
return $this->manualMail;
}
public function setManualMail(?Mail $manualMail): self
{
$this->manualMail = $manualMail;
return $this;
}
public function getSentAt(): ?\DateTimeInterface
{
return $this->sentAt;
}
public function setSentAt(?\DateTimeInterface $sentAt): self
{
$this->sentAt = $sentAt;
return $this;
}
public function getExternalId(): ?string
{
return $this->externalId;
}
public function setExternalId(?string $externalId): self
{
$this->externalId = $externalId;
return $this;
}
public function getExternalCandidateId(): ?string
{
return $this->externalCandidateId;
}
public function setExternalCandidateId(?string $externalCandidateId): self
{
$this->externalCandidateId = $externalCandidateId;
return $this;
}
public function hasExternalIds(): bool
{
return \is_string($this->getExternalId()) && \is_string($this->getExternalCandidateId());
}
public function getUtm(): ?array
{
return $this->utm;
}
public function setUtm(?array $utm): self
{
$this->utm = $utm;
return $this;
}
public function getKnockoutQuestionAnswers(): ?array
{
return $this->knockoutQuestionAnswers;
}
public function setKnockoutQuestionAnswers(?array $knockoutQuestionAnswers): self
{
$this->knockoutQuestionAnswers = $knockoutQuestionAnswers;
return $this;
}
public function isRejectedByKnockout(): bool
{
return $this->rejectedByKnockout;
}
public function setRejectedByKnockout(bool $rejectedByKnockout): self
{
$this->rejectedByKnockout = $rejectedByKnockout;
return $this;
}
public function getGdpr(): ?GdprStatement
{
return $this->gdpr;
}
public function setGdpr(?GdprStatement $gdpr): self
{
$this->gdpr = $gdpr;
return $this;
}
public function getAcceptedPrivacyPolicy(): ?bool
{
return $this->acceptedPrivacyPolicy;
}
public function getApplicantSendToApplicantMail(): ?bool
{
return $this->applicantSendToApplicantMail;
}
public function getClone(): ?bool
{
return $this->clone;
}
public function getManual(): ?bool
{
return $this->manual;
}
public function getUpdatedAt(): ?\DateTimeInterface
{
return $this->updatedAt;
}
public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
{
$this->updatedAt = $updatedAt;
return $this;
}
public function getRejectedByKnockout(): ?bool
{
return $this->rejectedByKnockout;
}
public function removeNote(Note $note): self
{
if ($this->notes->contains($note)) {
$this->notes->removeElement($note);
// set the owning side to null (unless already changed)
if ($note->getApplicant() === $this) {
$note->setApplicant(null);
}
}
return $this;
}
public function getExternalResumeId(): ?string
{
return $this->externalResumeId;
}
public function setExternalResumeId(?string $externalResumeId): self
{
$this->externalResumeId = $externalResumeId;
return $this;
}
public function getLocale(): ?string
{
return $this->locale;
}
public function setLocale(?string $locale): self
{
$this->locale = $locale;
return $this;
}
public function getApplyUrl(): ?string
{
return $this->applyUrl;
}
public function setApplyUrl(?string $applyUrl): self
{
$this->applyUrl = $applyUrl;
return $this;
}
public function isOpenApplication(): bool
{
return !$this->getVacancy() instanceof Vacancy;
}
public function addCVFile(?string $cvFileName, ?string $pathPrefix): void
{
if (null === $cvFileName) {
return;
}
if (null === $pathPrefix) {
return;
}
$this->setCVFile(new UploadedFile(
sprintf('%s%s', $pathPrefix, $cvFileName),
$cvFileName
));
}
public function getCompany(): ?Company
{
return $this->company;
}
public function setCompany(?Company $company): self
{
$this->company = $company;
return $this;
}
public function getApplicantForm(): ?ApplicantForm
{
return $this->applicantForm;
}
public function setApplicantForm(?ApplicantForm $applicantForm): self
{
$this->applicantForm = $applicantForm;
return $this;
}
public function getExternalVacancyReference(): ?string
{
if ($this->getVacancy() instanceof Vacancy) {
return $this->getVacancy()->getExternalReference();
}
if (\is_string($this->getApplicantForm()?->getExternalReference())) {
return $this->getApplicantForm()->getExternalReference();
}
return null;
}
public function getExternalVacancyId(): ?string
{
if ($this->getVacancy() instanceof Vacancy) {
return $this->getVacancy()->getExternalId();
}
if (\is_string($this->getApplicantForm()?->getExternalVacancyId())) {
return $this->getApplicantForm()->getExternalVacancyId();
}
return null;
}
}