<?php
namespace App\Entity;
use App\Repository\JobOfferRepository;
use Cofondateur\SocleTechniqueBundle\Annotation\CrudField;
use Cofondateur\SocleTechniqueBundle\Traits\SEOInterface;
use Cofondateur\SocleTechniqueBundle\Traits\SEOTrait;
use Cofondateur\SocleTechniqueBundle\Traits\SluggableInterface;
use Cofondateur\SocleTechniqueBundle\Traits\SluggableTrait;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Vich\UploaderBundle\Mapping\Annotation\Uploadable;
use App\Form\JobOfferParagraphFormType;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity(repositoryClass=JobOfferRepository::class)
* @UniqueEntity(
* fields={"slug"},
* errorPath="slug",
* message="Ce slug est déjà utilisé pour une autre offre d'emploi"
* )
* @Uploadable()
*/
class JobOffer implements SEOInterface, SluggableInterface
{
use SEOTrait;
use SluggableTrait;
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
* @CrudField(index=true, label="Titre de l'offre d'emploi")
*/
private $title;
/**
* @ORM\Column(type="string", length=255)
*/
private $idPost;
/**
* @ORM\Column(type="string", length=255)
* @CrudField(label="Ville", index=true)
*/
private $city;
/**
* @ORM\ManyToOne(targetEntity=JobOfferType::class, inversedBy="jobOffers")
* @CrudField(label="Type", index=true)
*/
private $type;
/**
* @ORM\Column(type="text")
* @CrudField(label="Résumé")
*/
private $resume;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $visuelOtherPageName;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $visuelOtherPageSize;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $visuelOtherPageUpdatedAt;
/**
* @Vich\UploadableField(mapping="default", fileNameProperty="visuelOtherPageName", size="visuelOtherPageSize")
* @CrudField(label="Visuel sur la page liste")
*/
private $visuelOtherPageFile;
/**
* @ORM\Column(type="string", nullable=true)
* @CrudField(label="Alt")
*/
private $visuelOtherPageAlt;
/**
* @ORM\Column(type="string", nullable=true)
*/
private $coverName;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $coverSize;
/**
* @ORM\Column(type="datetime", nullable=true)
*/
private $coverUpdatedAt;
/**
* @Vich\UploadableField(mapping="default", fileNameProperty="coverName", size="coverSize")
* @CrudField(label="Visuel principal (bandeau top)")
*/
private $coverFile;
/**
* @ORM\Column(type="string", nullable=true)
* @CrudField(label="Alt")
*/
private $coverAlt;
/**
* @ORM\OneToMany(targetEntity=JobOfferParagraph::class, mappedBy="jobOffer", orphanRemoval=true, cascade={"persist", "remove"})
* @ORM\OrderBy({"position"="ASC"})
* @CrudField(label="Paragraphes", formType=JobOfferParagraphFormType::class, sortable="position", tab="Paragraphes")
*/
private $paragraphs;
/**
* @ORM\OneToMany(targetEntity=JobOfferCandidacy::class, mappedBy="jobOffer")
*/
private $jobOfferCandidacies;
/**
* @ORM\Column(type="boolean", nullable=true)
* @CrudField(label="Affiché sur le site", index=true)
*/
private $published;
public function __construct()
{
$this->paragraphs = new ArrayCollection();
$this->jobOfferCandidacies = new ArrayCollection();
}
public function __toString(): string
{
return $this->getTitle() . " " . $this->getIdPost() ?? $this->getId() ?? "N/A";
}
public function getId(): ?int
{
return $this->id;
}
public function getTitle(): ?string
{
return $this->title;
}
public function setTitle(string $title): self
{
$this->title = $title;
return $this;
}
public function getIdPost(): ?string
{
return $this->idPost;
}
public function setIdPost(string $idPost): self
{
$this->idPost = $idPost;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city): self
{
$this->city = $city;
return $this;
}
public function getType(): ?JobOfferType
{
return $this->type;
}
public function setType(?JobOfferType $type): self
{
$this->type = $type;
return $this;
}
public function getResume(): ?string
{
return $this->resume;
}
public function setResume(string $resume): self
{
$this->resume = $resume;
return $this;
}
public function getVisuelOtherPageName(): ?string
{
return $this->visuelOtherPageName;
}
public function setVisuelOtherPageName(?string $visuelOtherPageName): self
{
$this->visuelOtherPageName = $visuelOtherPageName;
return $this;
}
public function getVisuelOtherPageSize(): ?int
{
return $this->visuelOtherPageSize;
}
public function setVisuelOtherPageSize(?int $visuelOtherPageSize): self
{
$this->visuelOtherPageSize = $visuelOtherPageSize;
return $this;
}
public function getVisuelOtherPageUpdatedAt(): ?\DateTimeInterface
{
return $this->visuelOtherPageUpdatedAt;
}
public function setVisuelOtherPageUpdatedAt(?\DateTimeInterface $visuelOtherPageUpdatedAt): self
{
$this->visuelOtherPageUpdatedAt = $visuelOtherPageUpdatedAt;
return $this;
}
public function getVisuelOtherPageFile(): ?File
{
return $this->visuelOtherPageFile;
}
public function setVisuelOtherPageFile(?File $visuelOtherPageFile): self
{
$this->visuelOtherPageFile = $visuelOtherPageFile;
if (null !== $this->visuelOtherPageFile) {
$this->visuelOtherPageUpdatedAt = new \DateTimeImmutable();
}
return $this;
}
public function getVisuelOtherPageAlt(): ?string
{
return $this->visuelOtherPageAlt;
}
public function setVisuelOtherPageAlt(?string $visuelOtherPageAlt): self
{
$this->visuelOtherPageAlt = $visuelOtherPageAlt;
return $this;
}
public function getCoverName(): ?string
{
return $this->coverName;
}
public function setCoverName(?string $coverName): self
{
$this->coverName = $coverName;
return $this;
}
public function getCoverSize(): ?int
{
return $this->coverSize;
}
public function setCoverSize(?int $coverSize): self
{
$this->coverSize = $coverSize;
return $this;
}
public function getCoverUpdatedAt(): ?\DateTimeInterface
{
return $this->coverUpdatedAt;
}
public function setCoverUpdatedAt(?\DateTimeInterface $coverUpdatedAt): self
{
$this->coverUpdatedAt = $coverUpdatedAt;
return $this;
}
public function getCoverFile(): ?File
{
return $this->coverFile;
}
public function setCoverFile(?File $coverFile): self
{
$this->coverFile = $coverFile;
if (null !== $this->coverFile) {
$this->coverUpdatedAt = new \DateTimeImmutable();
}
return $this;
}
public function getCoverAlt(): ?string
{
return $this->coverAlt;
}
public function setCoverAlt(?string $coverAlt): self
{
$this->coverAlt = $coverAlt;
return $this;
}
/**
* @return Collection<int, JobOfferParagraph>
*/
public function getParagraphs(): Collection
{
return $this->paragraphs;
}
public function addParagraph(JobOfferParagraph $paragraph): self
{
if (!$this->paragraphs->contains($paragraph)) {
$this->paragraphs[] = $paragraph;
$paragraph->setJobOffer($this);
}
return $this;
}
public function removeParagraph(JobOfferParagraph $paragraph): self
{
if ($this->paragraphs->removeElement($paragraph)) {
// set the owning side to null (unless already changed)
if ($paragraph->getJobOffer() === $this) {
$paragraph->setJobOffer(null);
}
}
return $this;
}
/**
* @return Collection<int, JobOfferCandidacy>
*/
public function getJobOfferCandidacies(): Collection
{
return $this->jobOfferCandidacies;
}
public function addJobOfferCandidacy(JobOfferCandidacy $jobOfferCandidacy): self
{
if (!$this->jobOfferCandidacies->contains($jobOfferCandidacy)) {
$this->jobOfferCandidacies[] = $jobOfferCandidacy;
$jobOfferCandidacy->setJobOffer($this);
}
return $this;
}
public function removeJobOfferCandidacy(JobOfferCandidacy $jobOfferCandidacy): self
{
if ($this->jobOfferCandidacies->removeElement($jobOfferCandidacy)) {
// set the owning side to null (unless already changed)
if ($jobOfferCandidacy->getJobOffer() === $this) {
$jobOfferCandidacy->setJobOffer(null);
}
}
return $this;
}
public function isPublished(): ?bool
{
return $this->published;
}
public function setPublished(?bool $published): self
{
$this->published = $published;
return $this;
}
}