<?php
namespace App\Entity;
use App\Repository\ProfileRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Normalizer\NormalizableInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\String\Slugger\AsciiSlugger;
/**
* @ORM\Entity(repositoryClass=ProfileRepository::class)
*/
class Profile implements NormalizableInterface
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
public $id;
/**
* @ORM\Column(type="integer", nullable=true)
*/
public $cost;
/**
* @ORM\Column(type="smallint")
*/
public $cost_type = 0;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
public $experience_number;
/**
* @ORM\Column(type="smallint", nullable=true)
*/
public $profile_type = 0;
/**
* @ORM\Column(type="text", nullable=true)
*/
public $about;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
public $photo;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
public $cv_file;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
public $location;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
public $location2;
/**
* @ORM\Column(type="json", nullable=true)
*/
public $mobility = [];
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
public $disponibility;
/**
* @ORM\ManyToOne(targetEntity=User::class, inversedBy="profiles")
* @ORM\JoinColumn(nullable=false, onDelete="CASCADE")
*/
public $user;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
public $name;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
public $linkedin;
/**
* @ORM\Column(type="string", length=255)
*/
public $title;
/**
* @ORM\OneToMany(targetEntity=Skill::class, mappedBy="profile", orphanRemoval=true, cascade={"persist"})
*/
public $skills;
/**
* @ORM\OneToMany(targetEntity=Experience::class, mappedBy="profile", orphanRemoval=true, cascade={"persist"})
*/
public $experiences;
/**
* @ORM\OneToMany(targetEntity=Diplome::class, mappedBy="profile", orphanRemoval=true, cascade={"persist"})
*/
public $diplomes;
/**
* @ORM\OneToMany(targetEntity=Certification::class, mappedBy="profile", cascade={"persist"})
*/
public $certifications;
/**
* @ORM\OneToMany(targetEntity=Candidature::class, mappedBy="profile")
*/
public $candidatures;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
public $isIntercontrat;
/**
* @ORM\OneToMany(targetEntity=ProfileVisit::class, mappedBy="profile", orphanRemoval=true)
*/
public $profileVisits;
/**
* @ORM\Column(type="string", length=150, nullable=true)
*/
public $firstname;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
public $englishLevel;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
public $legalStatus;
/**
* @ORM\Column(type="string", length=20, nullable=true)
*/
public $phone;
/**
* @ORM\Column(type="string", length=150, nullable=true)
*/
public $url;
/**
* @ORM\Column(type="string", length=190, nullable=true)
*/
public $cvname;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
public $isVisible;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
public $isHighlight;
/**
* @ORM\OneToMany(targetEntity=ProfileFavorite::class, mappedBy="profile")
*/
private $profileFavorites;
/**
*
* @ORM\ManyToOne(targetEntity=User::class)
*/
private $userRecruteur;
/**
*
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $cvOlderScan;
/**
* @ORM\Column(type="text", nullable=true)
*/
public $cvText;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $typeSearch;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $birthday;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $nationality;
/**
* @ORM\Column(type="json", nullable=true)
*/
private $nationalityMultiple;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
private $visaStatus;
/**
* @ORM\Column(type="string", length=50, nullable=true)
*/
public $arabicLevel;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $totalExp;
/**
* @ORM\Column(type="integer", nullable=true)
*/
public $salaryPerMonth;
/**
* @ORM\Column(type="integer", nullable=true)
*/
public $salaryPerHour;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $isInvisible;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $civility;
/**
* @ORM\Column(type="string", length=150, nullable=true)
*/
public $slug;
public function __construct()
{
$this->skills = new ArrayCollection();
$this->experiences = new ArrayCollection();
$this->diplomes = new ArrayCollection();
$this->certifications = new ArrayCollection();
$this->candidatures = new ArrayCollection();
$this->profileVisits = new ArrayCollection();
$this->profileFavorites = new ArrayCollection();
$this->typeSearch = "Full-time";
}
//----------------------------------
public function getCivilityString(): string
{
if ($this->getUser()){
if ($this->getUser()->getType() == "freelance"){
return $this->getUser()->getCivilityString();
}
}
return "";
}
public function getCurrentLocation(): ?string
{
return ($this->location == "United Arab Emirates") ? $this->location2 : $this->location;
}
public function getSalaryPeerMonthText(){
if($this->salaryPerMonth){
return $this->salaryPerMonth.' AED';
}
return "";
}
public function getSalaryPeerHourText(){
if($this->salaryPerHour){
return $this->salaryPerHour.' AED';
}
return "";
}
public function updateSlug(){
$slugger = new AsciiSlugger();
$defaultNum = 10000;
$numero = $defaultNum + $this->getId();
$slug = strtolower($slugger->slug($numero.'-'.$this->getName()));
$this->setSlug($slug);
}
//----------------------------------
public function getId(): ?int
{
return $this->id;
}
public function setId(int $id): self
{
$this->id = $id;
return $this;
}
public function getCost(): ?int
{
return $this->cost;
}
public function setCost(int $cost): self
{
$this->cost = $cost;
return $this;
}
public function getCostType(): ?int
{
return $this->cost_type;
}
public function setCostType(int $cost_type): self
{
$this->cost_type = $cost_type;
return $this;
}
public function getExperienceNumber(): ?string
{
return $this->experience_number;
}
public function setExperienceNumber(string $experience_number): self
{
$this->experience_number = $experience_number;
return $this;
}
public function getProfileType(): ?int
{
return $this->profile_type;
}
public function setProfileType(int $profile_type): self
{
$this->profile_type = $profile_type;
return $this;
}
public function getPhoto(): ?string
{
return $this->photo;
}
public function setPhoto(?string $photo): self
{
$this->photo = $photo;
return $this;
}
public function getCvFile(): ?string
{
return $this->cv_file;
}
public function setCvFile(?string $cv_file): self
{
$this->cv_file = $cv_file;
return $this;
}
public function getLocation(): ?string
{
return $this->location;
}
public function setLocation(string $location): self
{
$this->location = $location;
return $this;
}
public function getMobility(): ?array
{
return $this->mobility;
}
public function setMobility(?array $mobility): self
{
$this->mobility = $mobility;
return $this;
}
public function getDisponibility(): ?string
{
return $this->disponibility;
}
public function setDisponibility(string $disponibility): self
{
$this->disponibility = $disponibility;
return $this;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user): self
{
$this->user = $user;
return $this;
}
public function getFullName(): ?string
{
return $this->firstname. ' ' . $this->name;
}
public function isPrivate(): bool
{
return $this->profile_type === \App\Entity\Enum\Profile::PRIVATE;
}
public function isPublic(): bool
{
return $this->profile_type === \App\Entity\Enum\Profile::PUBLIC;
}
public function isHidden(): bool
{
return $this->profile_type === \App\Entity\Enum\Profile::HIDDEN;
}
public function getPublicName(): string
{
if ($this->isPrivate()) {
return $this->getFirstname()[0].'.';
}
return $this->getFullName();
}
public function getLinkedin(): ?string
{
return $this->linkedin;
}
public function setLinkedin(?string $linkedin): self
{
$this->linkedin = $linkedin;
return $this;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
/**
* @return Collection|Skill[]
*/
public function getSkills(): Collection
{
return $this->skills;
}
public function addSkill(Skill $skill): self
{
if (!$this->skills->contains($skill)) {
$this->skills->add($skill);
$skill->setProfile($this);
}
return $this;
}
public function removeSkill(Skill $skill): self
{
if ($this->skills->removeElement($skill)) {
// set the owning side to null (unless already changed)
if ($skill->getProfile() === $this) {
$skill->setProfile(null);
}
}
return $this;
}
/**
* @return Collection|Experience[]
*/
public function getExperiences(): Collection
{
return $this->experiences;
}
public function resetContent()
{
$this->experiences = new ArrayCollection();
$this->diplomes = new ArrayCollection();
$this->certifications = new ArrayCollection();
$this->skills = new ArrayCollection();
}
public function addExperience(Experience $experience): self
{
if (!$this->experiences->contains($experience)) {
$this->experiences->add($experience);
$experience->setProfile($this);
}
return $this;
}
public function removeExperience(Experience $experience): self
{
if ($this->experiences->removeElement($experience)) {
// set the owning side to null (unless already changed)
if ($experience->getProfile() === $this) {
$experience->setProfile(null);
}
}
return $this;
}
/**
* @return Collection|Diplome[]
*/
public function getDiplomes(): Collection
{
return $this->diplomes;
}
public function addDiplome(Diplome $diplome): self
{
if (!$this->diplomes->contains($diplome)) {
$this->diplomes->add($diplome);
$diplome->setProfile($this);
}
return $this;
}
public function removeDiplome(Diplome $diplome): self
{
if ($this->diplomes->removeElement($diplome)) {
// set the owning side to null (unless already changed)
if ($diplome->getProfile() === $this) {
$diplome->setProfile(null);
}
}
return $this;
}
/**
* @return Collection|Certification[]
*/
public function getCertifications(): Collection
{
return $this->certifications;
}
public function addCertification(Certification $certification): self
{
if (!$this->certifications->contains($certification)) {
$this->certifications[] = $certification;
$certification->setProfile($this);
}
return $this;
}
public function removeCertification(Certification $certification): self
{
if ($this->certifications->removeElement($certification)) {
// set the owning side to null (unless already changed)
if ($certification->getProfile() === $this) {
$certification->setProfile(null);
}
}
return $this;
}
/**
* @return Collection|Candidature[]
*/
public function getCandidatures(): Collection
{
return $this->candidatures;
}
public function addCandidature(Candidature $candidature): self
{
if (!$this->candidatures->contains($candidature)) {
$this->candidatures->add($candidature);
$candidature->setProfile($this);
}
return $this;
}
public function removeCandidature(Candidature $candidature): self
{
if ($this->candidatures->removeElement($candidature)) {
// set the owning side to null (unless already changed)
if ($candidature->getProfile() === $this) {
$candidature->setProfile(null);
}
}
return $this;
}
public function getIsIntercontrat(): ?bool
{
return $this->isIntercontrat;
}
public function setIsIntercontrat(?bool $isIntercontrat): self
{
$this->isIntercontrat = $isIntercontrat;
return $this;
}
/**
* @return Collection|ProfileVisit[]
*/
public function getProfileVisits(): Collection
{
return $this->profileVisits;
}
public function addProfileVisit(ProfileVisit $profileVisit): self
{
if (!$this->profileVisits->contains($profileVisit)) {
$this->profileVisits[] = $profileVisit;
$profileVisit->setProfile($this);
}
return $this;
}
public function removeProfileVisit(ProfileVisit $profileVisit): self
{
if ($this->profileVisits->removeElement($profileVisit)) {
// set the owning side to null (unless already changed)
if ($profileVisit->getProfile() === $this) {
$profileVisit->setProfile(null);
}
}
return $this;
}
public function getEnglishLevel(): ?string
{
return $this->englishLevel;
}
public function setEnglishLevel(string $englishLevel): self
{
$this->englishLevel = $englishLevel;
return $this;
}
public function getLegalStatus(): ?string
{
return $this->legalStatus;
}
public function setLegalStatus(string $legalStatus): self
{
$this->legalStatus = $legalStatus;
return $this;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(?string $url): self
{
$this->url = $url;
return $this;
}
public function normalize(NormalizerInterface $normalizer, string $format = null, array $context = [])
{
$experiences = [];
$formations = [];
$certifications = [];
$skills = [];
$experienceList = $this->getExperiences();
$formationList = $this->getDiplomes();
$certificationList = $this->getCertifications();
$skillList = $this->getSkills();
foreach ($experienceList as $experience) {
$experiences[] = [
'title' => $experience->getTitle(),
'environnement' => $experience->getEnvironment(),
'missions' => $experience->getMissions(),
'objectif' => $experience->getObjectif(),
];
}
foreach ($formationList as $formation) {
$formations[] = [
'title' => $formation->getTitle(),
'description' => $formation->getDescription(),
];
}
foreach ($certificationList as $certification) {
$certifications[] = $certification->getTitle();
}
foreach ($skillList as $skill) {
$skills[] = [
'name' => $skill->getName(),
'level' => $skill->getLevel(),
];
}
return [
'title' => $this->getTitle(),
'experiences' => $experiences,
'formations' => $formations,
'certifications' => $certifications,
'skills' => $skills,
'cost' => $this->getCost(),
'category' => $this->getIsIntercontrat() ? 'intercontrat' : 'profile',
'mobility' => $this->getMobility(),
'disponibility' => $this->getDisponibility(),
'visible' => $this->isVisible ?? false,
'highlight' => $this->isHighlight ?? false,
'description' => $this->getAbout(),
'identification' => $this->getId(),
];
}
public function getCvname(): ?string
{
return $this->cvname;
}
public function setCvname(?string $cvname): self
{
$this->cvname = $cvname;
return $this;
}
public function getIsVisible(): ?bool
{
return $this->isVisible;
}
public function setIsVisible(?bool $isVisible): self
{
$this->isVisible = $isVisible;
return $this;
}
public function getIsHighlight(): ?bool
{
return $this->isHighlight;
}
public function setIsHighlight(?bool $isHighlight): self
{
$this->isHighlight = $isHighlight;
return $this;
}
/**
* @return Collection<int, ProfileFavorite>
*/
public function getProfileFavorites(): Collection
{
return $this->profileFavorites;
}
public function addProfileFavorite(ProfileFavorite $profileFavorite): self
{
if (!$this->profileFavorites->contains($profileFavorite)) {
$this->profileFavorites[] = $profileFavorite;
$profileFavorite->setProfile($this);
}
return $this;
}
public function removeProfileFavorite(ProfileFavorite $profileFavorite): self
{
if ($this->profileFavorites->removeElement($profileFavorite)) {
// set the owning side to null (unless already changed)
if ($profileFavorite->getProfile() === $this) {
$profileFavorite->setProfile(null);
}
}
return $this;
}
public function getAbout(): ?string
{
return $this->about;
}
public function setAbout(?string $about): self
{
$this->about = $about;
return $this;
}
public function isIsIntercontrat(): ?bool
{
return $this->isIntercontrat;
}
public function getPhone(): ?string
{
return $this->phone;
}
public function setPhone(?string $phone): self
{
$this->phone = $phone;
return $this;
}
public function isIsVisible(): ?bool
{
return $this->isVisible;
}
public function isIsHighlight(): ?bool
{
return $this->isHighlight;
}
public function getUserRecruteur(): ?User
{
return $this->userRecruteur;
}
public function setUserRecruteur(?User $userRecruteur): self
{
$this->userRecruteur = $userRecruteur;
return $this;
}
public function getCvOlderScan(): ?string
{
return $this->cvOlderScan;
}
public function setCvOlderScan(?string $cvOlderScan): self
{
$this->cvOlderScan = $cvOlderScan;
return $this;
}
public function getCvText(): ?string
{
return $this->cvText;
}
public function setCvText(?string $cvText): self
{
$this->cvText = $cvText;
return $this;
}
public function getTypeSearch(): ?string
{
return $this->typeSearch;
}
public function setTypeSearch(?string $typeSearch): self
{
$this->typeSearch = $typeSearch;
return $this;
}
public function getBirthday(): ?\DateTimeInterface
{
return $this->birthday;
}
public function setBirthday(?\DateTimeInterface $birthday): self
{
$this->birthday = $birthday;
return $this;
}
public function getNationality(): ?string
{
return $this->nationality;
}
public function setNationality(?string $nationality): self
{
$this->nationality = $nationality;
return $this;
}
public function getVisaStatus(): ?string
{
return $this->visaStatus;
}
public function setVisaStatus(?string $visaStatus): self
{
$this->visaStatus = $visaStatus;
return $this;
}
public function getArabicLevel(): ?string
{
return $this->arabicLevel;
}
public function setArabicLevel(?string $arabicLevel): self
{
$this->arabicLevel = $arabicLevel;
return $this;
}
public function getTotalExp(): ?int
{
return $this->totalExp;
}
public function setTotalExp(?int $totalExp): self
{
$this->totalExp = $totalExp;
return $this;
}
public function getSalaryPerMonth(): ?int
{
return $this->salaryPerMonth;
}
public function setSalaryPerMonth(?int $salaryPerMonth): self
{
$this->salaryPerMonth = $salaryPerMonth;
return $this;
}
public function getSalaryPerHour(): ?int
{
return $this->salaryPerHour;
}
public function setSalaryPerHour(?int $salaryPerHour): self
{
$this->salaryPerHour = $salaryPerHour;
return $this;
}
public function isIsInvisible(): ?bool
{
if ($this->isInvisible == true){
return true;
}
return false;
}
public function setIsInvisible(?bool $isInvisible): self
{
$this->isInvisible = $isInvisible;
return $this;
}
public function getLocation2(): ?string
{
return $this->location2;
}
public function setLocation2(?string $location2): self
{
$this->location2 = $location2;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(?string $name): self
{
$this->name = $name;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(?string $firstname): self
{
$this->firstname = $firstname;
return $this;
}
public function getCivility(): ?int
{
return $this->civility;
}
public function setCivility(?int $civility): self
{
$this->civility = $civility;
return $this;
}
public function getNationalityMultiple(): ?array
{
return $this->nationalityMultiple;
}
public function setNationalityMultiple(?array $nationalityMultiple): self
{
$this->nationalityMultiple = $nationalityMultiple;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(?string $slug): self
{
$this->slug = $slug;
return $this;
}
}