<?php
declare(strict_types=1);
/*
* Copyright (C) Office National de Publication et de Communication - All Rights Reserved
*
* Unauthorized copying of this file, via any medium is strictly prohibited by law
* This file is proprietary and confidential
*/
namespace App\Entity;
use App\Entity\Common\IdTrait;
use DateTime;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass="App\Repository\OffreEmploiRepository")
* @ORM\Table(
* name="offre_emploi",
* indexes={
* @ORM\Index(columns={"date_creation"})
* }
* )
*/
class OffreEmploi
{
use IdTrait;
/** @ORM\Column(type="string", nullable=true) */
private $idDistant;
/** @ORM\Column(type="datetime", nullable=false) */
private $dateCreation;
/** @ORM\Column(type="datetime", nullable=false) */
private $dateActualisation;
/** @ORM\Column(type="datetime", nullable=true) */
private $dateValidite;
/** @ORM\Column(type="string", nullable=true) */
private $libelle; // ce champ n'est plus utilisé, remplace par "profil"
/** @ORM\Column(type="text", nullable=true) */
private $description;
/**
* @Assert\Url(protocols={"https"})
* @ORM\Column(type="string", nullable=true)
*/
private $url;
/**
* @Assert\Url
* @ORM\Column(type="string", nullable=true)
*/
private $urlImage;
/** @ORM\Column(type="text", nullable=true) */
private $jsonLd;
/**
* @ORM\ManyToOne(targetEntity="Etablissement", inversedBy="offresEmploi")
* @ORM\JoinColumn(nullable=false)
*/
private $etablissement;
/**
* @ORM\OneToMany(targetEntity="OffreEmploiCandidature", mappedBy="offreEmploi", cascade={"persist"}, fetch="EXTRA_LAZY")
*/
private $candidatures;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\OffreEmploiProfil", inversedBy="offreEmplois")
*/
private $profil;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\OffreEmploiContrat", inversedBy="offreEmplois")
*/
private $contrat;
public function __construct()
{
$this->candidatures = new ArrayCollection();
}
public function setIdDistant(string $idDistant): void
{
$this->idDistant = $idDistant;
}
public function getIdDistant(): ?string
{
return $this->idDistant;
}
public function setDateCreation(DateTime $date): void
{
$this->dateCreation = $date;
}
public function getDateCreation(): DateTime
{
return $this->dateCreation;
}
public function setDateActualisation(DateTime $date): void
{
$this->dateActualisation = $date;
}
public function getDateActualisation(): DateTime
{
return $this->dateActualisation;
}
public function setDateValidite(?DateTime $date): void
{
$this->dateValidite = $date;
}
public function getDateValidite(): ?DateTime
{
return $this->dateValidite;
}
public function isValid(): bool
{
return !$this->dateValidite || $this->dateValidite >= new DateTime();
}
public function setLibelle(string $libelle): void
{
// $this->libelle = $libelle;
// $this->libelle = $this->getProfil()->getLibelle();
// Résoudre le pb d'importation des anciennes offres
$this->libelle = $this->getProfil()->getId() == 999 ? $libelle : $this->getProfil()->getLibelle();
}
public function getLibelle(): ?string
{
// return $this->libelle;
// return $this->getProfil()->getLibelle();
// Résoudre le pb d'importation des anciennes offres
return $this->getProfil()->getId() == 999 ? $this->libelle : $this->getProfil()->getLibelle();
}
public function setDescription(?string $description): void
{
$this->description = $description;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setUrl(?string $url): void
{
$this->url = $url;
}
public function getUrl()
{
return $this->url;
}
public function setUrlImage(?string $urlImage): void
{
$this->urlImage = $urlImage;
}
public function getUrlImage(): ?string
{
return $this->urlImage;
}
public function setJsonLd(?string $jsonLd): void
{
$this->jsonLd = $jsonLd;
}
public function getJsonLd(): ?string
{
return $this->jsonLd;
}
public function setEtablissement(Etablissement $etablissement): void
{
$this->etablissement = $etablissement;
}
public function getEtablissement(): ?Etablissement
{
return $this->etablissement;
}
public function addCandidature(OffreEmploiCandidature $candidatures): void
{
$this->candidatures[] = $candidatures;
}
public function removeCandidature(OffreEmploiCandidature $candidatures): void
{
$this->candidatures->removeElement($candidatures);
}
public function getCandidature(): Collection
{
return $this->candidatures;
}
public function getProfil(): ?OffreEmploiProfil
{
return $this->profil;
}
public function setProfil(?OffreEmploiProfil $profil): self
{
$this->profil = $profil;
return $this;
}
public function getContrat(): ?OffreEmploiContrat
{
return $this->contrat;
}
public function setContrat(?OffreEmploiContrat $contrat): self
{
$this->contrat = $contrat;
return $this;
}
}