src/Entity/Actuality.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Traits\QuoteTrait;
  4. use App\Repository\ActualityRepository;
  5. use Cofondateur\SocleTechniqueBundle\Annotation\CrudField;
  6. use Cofondateur\SocleTechniqueBundle\Traits\SEOInterface;
  7. use Cofondateur\SocleTechniqueBundle\Traits\SEOTrait;
  8. use Cofondateur\SocleTechniqueBundle\Traits\SluggableInterface;
  9. use Cofondateur\SocleTechniqueBundle\Traits\SluggableTrait;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\Common\Collections\Collection;
  12. use Doctrine\ORM\Mapping as ORM;
  13. use Symfony\Component\HttpFoundation\File\File;
  14. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  15. use Vich\UploaderBundle\Mapping\Annotation\Uploadable;
  16. use App\Form\ActualityBlocFormType;
  17. /**
  18.  * @ORM\Entity(repositoryClass=ActualityRepository::class)
  19.  * @Uploadable()
  20.  */
  21. class Actuality implements SEOInterfaceSluggableInterface
  22. {
  23.     
  24.     use SEOTrait;
  25.     use QuoteTrait;
  26.     use SluggableTrait;
  27.     
  28.     /**
  29.      * @ORM\Id
  30.      * @ORM\GeneratedValue
  31.      * @ORM\Column(type="integer")
  32.      */
  33.     private $id;
  34.     /**
  35.      * @ORM\Column(type="string")
  36.      */
  37.     private $coverName;
  38.     /**
  39.      * @ORM\Column(type="integer")
  40.      */
  41.     private $coverSize;
  42.     /**
  43.      * @ORM\Column(type="datetime", nullable=true)
  44.      */
  45.     private $coverUpdatedAt;
  46.     /**
  47.      * @Vich\UploadableField(mapping="default", fileNameProperty="coverName", size="coverSize")
  48.      * @CrudField(label="Visuel principal (bandeau top)")
  49.      */
  50.     private $coverFile;
  51.     /**
  52.      * @ORM\Column(type="string", nullable=true)
  53.      * @CrudField(label="Alt du visuel principal")
  54.      */
  55.     private $coverAlt;
  56.     /**
  57.      * @ORM\Column(type="string", length=255)
  58.      * @CrudField(index=true, label="Titre")
  59.      */
  60.     private $title;
  61.     /**
  62.      * @ORM\Column(type="text")
  63.      * @CrudField(label="Résumé sur les autres pages")
  64.      */
  65.     private $resume;
  66.     /**
  67.      * @ORM\ManyToOne(targetEntity=ActualityCategory::class, inversedBy="actualities")
  68.      * @ORM\JoinColumn(nullable=false)
  69.      * @CrudField(label="Catégorie", index=true)
  70.      */
  71.     private $category;
  72.     /**
  73.      * @ORM\OneToMany(targetEntity=ActualityBloc::class, mappedBy="actuality", orphanRemoval=true, cascade={"persist", "remove"})
  74.      * @CrudField(label="Paragraphes", formType=ActualityBlocFormType::class, tab="Paragraphes")
  75.      */
  76.     private $paragraphs;
  77.     /**
  78.      * @Vich\UploadableField(mapping="default", fileNameProperty="quoteCoverName", size="quoteCoverSize")
  79.      * @CrudField(tab="Citation", label="Visuel de fond")
  80.      */
  81.     private $quoteCoverFile;
  82.     /**
  83.      * @ORM\Column(type="date")
  84.      * @CrudField(label="Date")
  85.      */
  86.     private $date;
  87.     /**
  88.      * @ORM\Column(type="boolean")
  89.      * @CrudField(index=true, label="Publié")
  90.      */
  91.     private $published;
  92.     public function __construct()
  93.     {
  94.         $this->paragraphs = new ArrayCollection();
  95.         $this->date = new \DateTime();
  96.     }
  97.     public function __toString(): string
  98.     {
  99.         return $this->getId() ?? "N/A";
  100.     }
  101.     public function getId(): ?int
  102.     {
  103.         return $this->id;
  104.     }
  105.     public function getCoverName(): ?string
  106.     {
  107.         return $this->coverName;
  108.     }
  109.     public function setCoverName(?string $coverName): self
  110.     {
  111.         $this->coverName $coverName;
  112.         return $this;
  113.     }
  114.     public function getCoverSize(): ?int
  115.     {
  116.         return $this->coverSize;
  117.     }
  118.     public function setCoverSize(?int $coverSize): self
  119.     {
  120.         $this->coverSize $coverSize;
  121.         return $this;
  122.     }
  123.     public function getCoverUpdatedAt(): ?\DateTimeInterface
  124.     {
  125.         return $this->coverUpdatedAt;
  126.     }
  127.     public function setCoverUpdatedAt(?\DateTimeInterface $coverUpdatedAt): self
  128.     {
  129.         $this->coverUpdatedAt $coverUpdatedAt;
  130.         return $this;
  131.     }
  132.     public function getCoverFile(): ?File
  133.     {
  134.         return $this->coverFile;
  135.     }
  136.     public function setCoverFile(?File $coverFile): self
  137.     {
  138.         $this->coverFile $coverFile;
  139.         if (null !== $this->coverFile) {
  140.             $this->coverUpdatedAt = new \DateTimeImmutable();
  141.         }
  142.         return $this;
  143.     }
  144.     public function getCoverAlt(): ?string
  145.     {
  146.         return $this->coverAlt;
  147.     }
  148.     public function setCoverAlt(?string $coverAlt): self
  149.     {
  150.         $this->coverAlt $coverAlt;
  151.         return $this;
  152.     }
  153.     public function getTitle(): ?string
  154.     {
  155.         return $this->title;
  156.     }
  157.     public function setTitle(string $title): self
  158.     {
  159.         $this->title $title;
  160.         return $this;
  161.     }
  162.     public function getResume(): ?string
  163.     {
  164.         return $this->resume;
  165.     }
  166.     public function setResume(string $resume): self
  167.     {
  168.         $this->resume $resume;
  169.         return $this;
  170.     }
  171.     public function getCategory(): ?ActualityCategory
  172.     {
  173.         return $this->category;
  174.     }
  175.     public function setCategory(?ActualityCategory $category): self
  176.     {
  177.         $this->category $category;
  178.         return $this;
  179.     }
  180.     /**
  181.      * @return Collection<int, ActualityBloc>
  182.      */
  183.     public function getParagraphs(): Collection
  184.     {
  185.         return $this->paragraphs;
  186.     }
  187.     public function addParagraph(ActualityBloc $paragraph): self
  188.     {
  189.         if (!$this->paragraphs->contains($paragraph)) {
  190.             $this->paragraphs[] = $paragraph;
  191.             $paragraph->setActuality($this);
  192.         }
  193.         return $this;
  194.     }
  195.     public function removeParagraph(ActualityBloc $paragraph): self
  196.     {
  197.         if ($this->paragraphs->removeElement($paragraph)) {
  198.             // set the owning side to null (unless already changed)
  199.             if ($paragraph->getActuality() === $this) {
  200.                 $paragraph->setActuality(null);
  201.             }
  202.         }
  203.         return $this;
  204.     }
  205.     public function getDate(): ?\DateTimeInterface
  206.     {
  207.         return $this->date;
  208.     }
  209.     public function getDateFormated(): ?string
  210.     {
  211.         // Vérifiez si la date est définie
  212.         if ($this->date instanceof \DateTimeInterface) {
  213.             // Utilisez la méthode format pour obtenir la date au format souhaité
  214.             return $this->date->format('d/m/Y');
  215.         }
  216.         return null;
  217.     }
  218.     public function setDate(\DateTimeInterface $date): self
  219.     {
  220.         $this->date $date;
  221.         return $this;
  222.     }
  223.     public function isPublished(): ?bool
  224.     {
  225.         return $this->published;
  226.     }
  227.     public function setPublished(bool $published): self
  228.     {
  229.         $this->published $published;
  230.         return $this;
  231.     }
  232. }