src/Entity/JobOffer.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\JobOfferRepository;
  4. use Cofondateur\SocleTechniqueBundle\Annotation\CrudField;
  5. use Cofondateur\SocleTechniqueBundle\Traits\SEOInterface;
  6. use Cofondateur\SocleTechniqueBundle\Traits\SEOTrait;
  7. use Cofondateur\SocleTechniqueBundle\Traits\SluggableInterface;
  8. use Cofondateur\SocleTechniqueBundle\Traits\SluggableTrait;
  9. use Doctrine\ORM\Mapping as ORM;
  10. use Symfony\Component\HttpFoundation\File\File;
  11. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  12. use Vich\UploaderBundle\Mapping\Annotation\Uploadable;
  13. use App\Form\JobOfferParagraphFormType;
  14. use Doctrine\Common\Collections\ArrayCollection;
  15. use Doctrine\Common\Collections\Collection;
  16. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  17. use Symfony\Component\Validator\Constraints as Assert;
  18. /**
  19.  * @ORM\Entity(repositoryClass=JobOfferRepository::class)
  20.  * @UniqueEntity(
  21.  *     fields={"slug"},
  22.  *     errorPath="slug",
  23.  *     message="Ce slug est déjà utilisé pour une autre offre d'emploi"
  24.  * )
  25.  * @Uploadable()
  26.  */
  27. class JobOffer implements SEOInterfaceSluggableInterface
  28. {
  29.     
  30.     use SEOTrait;
  31.         
  32.     use SluggableTrait;
  33.     
  34.     /**
  35.      * @ORM\Id
  36.      * @ORM\GeneratedValue
  37.      * @ORM\Column(type="integer")
  38.      */
  39.     private $id;
  40.     /**
  41.      * @ORM\Column(type="string", length=255)
  42.      * @CrudField(index=true, label="Titre de l'offre d'emploi")
  43.      */
  44.     private $title;
  45.     /**
  46.      * @ORM\Column(type="string", length=255)
  47.      */
  48.     private $idPost;
  49.     /**
  50.      * @ORM\Column(type="string", length=255)
  51.      * @CrudField(label="Ville", index=true)
  52.      */
  53.     private $city;
  54.     /**
  55.      * @ORM\ManyToOne(targetEntity=JobOfferType::class, inversedBy="jobOffers")
  56.      * @CrudField(label="Type", index=true)
  57.      */
  58.     private $type;
  59.     /**
  60.      * @ORM\Column(type="text")
  61.      * @CrudField(label="Résumé")
  62.      */
  63.     private $resume;
  64.     /**
  65.      * @ORM\Column(type="string", nullable=true)
  66.      */
  67.     private $visuelOtherPageName;
  68.     /**
  69.      * @ORM\Column(type="integer", nullable=true)
  70.      */
  71.     private $visuelOtherPageSize;
  72.     /**
  73.      * @ORM\Column(type="datetime", nullable=true)
  74.      */
  75.     private $visuelOtherPageUpdatedAt;
  76.     /**
  77.      * @Vich\UploadableField(mapping="default", fileNameProperty="visuelOtherPageName", size="visuelOtherPageSize")
  78.      * @CrudField(label="Visuel sur la page liste")
  79.      */
  80.     private $visuelOtherPageFile;
  81.     /**
  82.      * @ORM\Column(type="string", nullable=true)
  83.      * @CrudField(label="Alt")
  84.      */
  85.     private $visuelOtherPageAlt;
  86.     /**
  87.      * @ORM\Column(type="string", nullable=true)
  88.      */
  89.     private $coverName;
  90.     /**
  91.      * @ORM\Column(type="integer", nullable=true)
  92.      */
  93.     private $coverSize;
  94.     /**
  95.      * @ORM\Column(type="datetime", nullable=true)
  96.      */
  97.     private $coverUpdatedAt;
  98.     /**
  99.      * @Vich\UploadableField(mapping="default", fileNameProperty="coverName", size="coverSize")
  100.      * @CrudField(label="Visuel principal (bandeau top)")
  101.      */
  102.     private $coverFile;
  103.     /**
  104.      * @ORM\Column(type="string", nullable=true)
  105.      * @CrudField(label="Alt")
  106.      */
  107.     private $coverAlt;
  108.     /**
  109.      * @ORM\OneToMany(targetEntity=JobOfferParagraph::class, mappedBy="jobOffer", orphanRemoval=true, cascade={"persist", "remove"})
  110.      * @ORM\OrderBy({"position"="ASC"})
  111.      * @CrudField(label="Paragraphes", formType=JobOfferParagraphFormType::class, sortable="position", tab="Paragraphes")
  112.      */
  113.     private $paragraphs;
  114.     /**
  115.      * @ORM\OneToMany(targetEntity=JobOfferCandidacy::class, mappedBy="jobOffer")
  116.      */
  117.     private $jobOfferCandidacies;
  118.     /**
  119.      * @ORM\Column(type="boolean", nullable=true)
  120.      * @CrudField(label="Affiché sur le site", index=true)
  121.      */
  122.     private $published;
  123.     public function __construct()
  124.     {
  125.         $this->paragraphs = new ArrayCollection();
  126.         $this->jobOfferCandidacies = new ArrayCollection();
  127.     }
  128.     public function __toString(): string
  129.     {
  130.         return $this->getTitle() . " " $this->getIdPost() ?? $this->getId() ?? "N/A";
  131.     }
  132.     public function getId(): ?int
  133.     {
  134.         return $this->id;
  135.     }
  136.     public function getTitle(): ?string
  137.     {
  138.         return $this->title;
  139.     }
  140.     public function setTitle(string $title): self
  141.     {
  142.         $this->title $title;
  143.         return $this;
  144.     }
  145.     public function getIdPost(): ?string
  146.     {
  147.         return $this->idPost;
  148.     }
  149.     public function setIdPost(string $idPost): self
  150.     {
  151.         $this->idPost $idPost;
  152.         return $this;
  153.     }
  154.     public function getCity(): ?string
  155.     {
  156.         return $this->city;
  157.     }
  158.     public function setCity(string $city): self
  159.     {
  160.         $this->city $city;
  161.         return $this;
  162.     }
  163.     public function getType(): ?JobOfferType
  164.     {
  165.         return $this->type;
  166.     }
  167.     public function setType(?JobOfferType $type): self
  168.     {
  169.         $this->type $type;
  170.         return $this;
  171.     }
  172.     public function getResume(): ?string
  173.     {
  174.         return $this->resume;
  175.     }
  176.     public function setResume(string $resume): self
  177.     {
  178.         $this->resume $resume;
  179.         return $this;
  180.     }
  181.     public function getVisuelOtherPageName(): ?string
  182.     {
  183.         return $this->visuelOtherPageName;
  184.     }
  185.     public function setVisuelOtherPageName(?string $visuelOtherPageName): self
  186.     {
  187.         $this->visuelOtherPageName $visuelOtherPageName;
  188.         return $this;
  189.     }
  190.     public function getVisuelOtherPageSize(): ?int
  191.     {
  192.         return $this->visuelOtherPageSize;
  193.     }
  194.     public function setVisuelOtherPageSize(?int $visuelOtherPageSize): self
  195.     {
  196.         $this->visuelOtherPageSize $visuelOtherPageSize;
  197.         return $this;
  198.     }
  199.     public function getVisuelOtherPageUpdatedAt(): ?\DateTimeInterface
  200.     {
  201.         return $this->visuelOtherPageUpdatedAt;
  202.     }
  203.     public function setVisuelOtherPageUpdatedAt(?\DateTimeInterface $visuelOtherPageUpdatedAt): self
  204.     {
  205.         $this->visuelOtherPageUpdatedAt $visuelOtherPageUpdatedAt;
  206.         return $this;
  207.     }
  208.     public function getVisuelOtherPageFile(): ?File
  209.     {
  210.         return $this->visuelOtherPageFile;
  211.     }
  212.     public function setVisuelOtherPageFile(?File $visuelOtherPageFile): self
  213.     {
  214.         $this->visuelOtherPageFile $visuelOtherPageFile;
  215.         if (null !== $this->visuelOtherPageFile) {
  216.             $this->visuelOtherPageUpdatedAt = new \DateTimeImmutable();
  217.         }
  218.         return $this;
  219.     }
  220.     public function getVisuelOtherPageAlt(): ?string
  221.     {
  222.         return $this->visuelOtherPageAlt;
  223.     }
  224.     public function setVisuelOtherPageAlt(?string $visuelOtherPageAlt): self
  225.     {
  226.         $this->visuelOtherPageAlt $visuelOtherPageAlt;
  227.         return $this;
  228.     }
  229.     public function getCoverName(): ?string
  230.     {
  231.         return $this->coverName;
  232.     }
  233.     public function setCoverName(?string $coverName): self
  234.     {
  235.         $this->coverName $coverName;
  236.         return $this;
  237.     }
  238.     public function getCoverSize(): ?int
  239.     {
  240.         return $this->coverSize;
  241.     }
  242.     public function setCoverSize(?int $coverSize): self
  243.     {
  244.         $this->coverSize $coverSize;
  245.         return $this;
  246.     }
  247.     public function getCoverUpdatedAt(): ?\DateTimeInterface
  248.     {
  249.         return $this->coverUpdatedAt;
  250.     }
  251.     public function setCoverUpdatedAt(?\DateTimeInterface $coverUpdatedAt): self
  252.     {
  253.         $this->coverUpdatedAt $coverUpdatedAt;
  254.         return $this;
  255.     }
  256.     public function getCoverFile(): ?File
  257.     {
  258.         return $this->coverFile;
  259.     }
  260.     public function setCoverFile(?File $coverFile): self
  261.     {
  262.         $this->coverFile $coverFile;
  263.         if (null !== $this->coverFile) {
  264.             $this->coverUpdatedAt = new \DateTimeImmutable();
  265.         }
  266.         return $this;
  267.     }
  268.     public function getCoverAlt(): ?string
  269.     {
  270.         return $this->coverAlt;
  271.     }
  272.     public function setCoverAlt(?string $coverAlt): self
  273.     {
  274.         $this->coverAlt $coverAlt;
  275.         return $this;
  276.     }
  277.     /**
  278.      * @return Collection<int, JobOfferParagraph>
  279.      */
  280.     public function getParagraphs(): Collection
  281.     {
  282.         return $this->paragraphs;
  283.     }
  284.     public function addParagraph(JobOfferParagraph $paragraph): self
  285.     {
  286.         if (!$this->paragraphs->contains($paragraph)) {
  287.             $this->paragraphs[] = $paragraph;
  288.             $paragraph->setJobOffer($this);
  289.         }
  290.         return $this;
  291.     }
  292.     public function removeParagraph(JobOfferParagraph $paragraph): self
  293.     {
  294.         if ($this->paragraphs->removeElement($paragraph)) {
  295.             // set the owning side to null (unless already changed)
  296.             if ($paragraph->getJobOffer() === $this) {
  297.                 $paragraph->setJobOffer(null);
  298.             }
  299.         }
  300.         return $this;
  301.     }
  302.     /**
  303.      * @return Collection<int, JobOfferCandidacy>
  304.      */
  305.     public function getJobOfferCandidacies(): Collection
  306.     {
  307.         return $this->jobOfferCandidacies;
  308.     }
  309.     public function addJobOfferCandidacy(JobOfferCandidacy $jobOfferCandidacy): self
  310.     {
  311.         if (!$this->jobOfferCandidacies->contains($jobOfferCandidacy)) {
  312.             $this->jobOfferCandidacies[] = $jobOfferCandidacy;
  313.             $jobOfferCandidacy->setJobOffer($this);
  314.         }
  315.         return $this;
  316.     }
  317.     public function removeJobOfferCandidacy(JobOfferCandidacy $jobOfferCandidacy): self
  318.     {
  319.         if ($this->jobOfferCandidacies->removeElement($jobOfferCandidacy)) {
  320.             // set the owning side to null (unless already changed)
  321.             if ($jobOfferCandidacy->getJobOffer() === $this) {
  322.                 $jobOfferCandidacy->setJobOffer(null);
  323.             }
  324.         }
  325.         return $this;
  326.     }
  327.     public function isPublished(): ?bool
  328.     {
  329.         return $this->published;
  330.     }
  331.     public function setPublished(?bool $published): self
  332.     {
  333.         $this->published $published;
  334.         return $this;
  335.     }
  336. }