src/Entity/Tuto.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\TutoRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Vich\UploaderBundle\Entity\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. /**
  11.  * @ORM\Entity(repositoryClass=TutoRepository::class)
  12.  * @Vich\Uploadable
  13.  */
  14. class Tuto
  15. {
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="boolean", nullable=false)
  24.      */
  25.     private bool $active true
  26.     
  27.     /**
  28.      * @ORM\ManyToOne(targetEntity=LaBaseCategory::class)
  29.      * @ORM\JoinColumn(nullable=true)
  30.      */
  31.     private LaBaseCategory $category;
  32.     /**
  33.      * @Assert\NotBlank()
  34.      * @ORM\Column(type="string", length=255)
  35.      */
  36.     private ?string $title;
  37.     /**
  38.      * @Assert\NotBlank()
  39.      * @ORM\Column(type="text")
  40.      */
  41.     private ?string $content;
  42.     /**
  43.      * @ORM\Column(type="text")
  44.      */
  45.     private string $chapo;
  46.     
  47.     /**
  48.      * @ORM\Column(type="datetime", nullable=true)
  49.      */
  50.     private $createdAt;
  51.     /**
  52.      * @ORM\ManyToOne(targetEntity=User::class)
  53.      * @ORM\JoinColumn(nullable=true)
  54.      */
  55.     private ?User $author;
  56.     /**
  57.      * @ORM\ManyToMany(targetEntity="App\Entity\Keywords", inversedBy="mentionsTutos", cascade={"persist"})
  58.      * @ORM\JoinTable(name="tutos_keywords")
  59.      * @ORM\OrderBy({"keyword" = "ASC"})
  60.      */
  61.     private $listekeywords;
  62.     /**
  63.      * @ORM\ManyToMany(targetEntity="App\Entity\Lexique", inversedBy="mentionsTutos", cascade={"persist"})
  64.      * @ORM\JoinTable(name="tutos_lexiques")
  65.      * @ORM\OrderBy({"word" = "ASC"})
  66.      */
  67.     private $listelexique;
  68.     /**
  69.      * @ORM\Column(type="string", length=255, nullable=true)
  70.      * @var string
  71.      */
  72.     private $pdf;
  73.     /**
  74.      * @Vich\UploadableField(mapping="labase_pdf", fileNameProperty="pdf")
  75.      * @var File
  76.      */
  77.     private $pdfFile;
  78.     /**
  79.      * @ORM\Column(type="boolean")
  80.      */
  81.     private bool $pinned false;
  82.     public function __construct()
  83.     {
  84.         $this->createdAt = new \DateTime();
  85.         $this->updatedAt = new \DateTime();
  86.         $this->listekeywords = new ArrayCollection();
  87.         $this->listelexique = new ArrayCollection();
  88.     }
  89.     public function getId(): ?int
  90.     {
  91.         return $this->id;
  92.     }
  93.     public function getCategory(): ?LaBaseCategory
  94.     {
  95.         return $this->category;
  96.     }
  97.     public function setCategory(LaBaseCategory $category): void
  98.     {
  99.         $this->category $category;
  100.     }
  101.     public function getTitle(): ?string
  102.     {
  103.         return $this->title;
  104.     }
  105.     public function setTitle(string $title): self
  106.     {
  107.         $this->title $title;
  108.         return $this;
  109.     }
  110.     public function getContent(): ?string
  111.     {
  112.         return $this->content;
  113.     }
  114.     public function setContent(string $content): self
  115.     {
  116.         $this->content $content;
  117.         return $this;
  118.     }
  119.     public function getCreatedAt(): ?\DateTimeInterface
  120.     {
  121.         return $this->createdAt;
  122.     }
  123.     
  124.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  125.     {
  126.         $this->createdAt $createdAt;
  127.     
  128.         return $this;
  129.     }
  130.     public function isActive(): bool
  131.     {
  132.         return $this->active;
  133.     }
  134.     public function setActive(bool $active): void
  135.     {
  136.         $this->active $active;
  137.     }
  138.     public function getAuthor(): ?User
  139.     {
  140.         return $this->author;
  141.     }
  142.     public function setAuthor(?User $author): void
  143.     {
  144.         $this->author $author;
  145.     }
  146.     public function getTags(): array
  147.     {
  148.         return $this->tags;
  149.     }
  150.     public function setTags(array $tags): void
  151.     {
  152.         $this->tags $tags;
  153.     }
  154.     public function getListelexique(): Collection
  155.     {
  156.         return $this->listelexique;
  157.     }
  158.     public function addListelexique(Lexique $lexique): self
  159.     {
  160.         if (!$this->listelexique->contains($lexique)) {
  161.             $this->listelexique[] = $lexique;
  162.         }
  163.         return $this;
  164.     }
  165.     public function removeListelexique(Lexique $lexique): self
  166.     {
  167.         $this->listelexique->removeElement($lexique);
  168.         return $this;
  169.     }
  170.     public function setPdfFile($pdf null)
  171.     {
  172.         $this->pdfFile $pdf;
  173.         // VERY IMPORTANT:
  174.         // It is required that at least one field changes if you are using Doctrine,
  175.         // otherwise the event listeners won't be called and the file is lost
  176.         if ($pdf) {
  177.             // if 'updatedAt' is not defined in your entity, use another property
  178.             $this->updatedAt = new \DateTime('now');
  179.         }
  180.     }
  181.     public function getPdfFile()
  182.     {
  183.         return $this->pdfFile;
  184.     }
  185.     public function setPdf($pdf)
  186.     {
  187.         // $pdf = str_replace(' ', '_', $pdf);
  188.         $this->pdf $pdf;
  189.     }
  190.     public function getPdf()
  191.     {
  192.         return $this->pdf;
  193.     }
  194.     /**
  195.      * @return Collection<int, Keywords>
  196.      */
  197.     public function getListekeywords(): Collection
  198.     {
  199.         return $this->listekeywords;
  200.     }
  201.     public function addListekeyword(Keywords $listekeyword): self
  202.     {
  203.         if (!$this->listekeywords->contains($listekeyword)) {
  204.             $this->listekeywords[] = $listekeyword;
  205.         }
  206.         return $this;
  207.     }
  208.     public function removeListekeyword(Keywords $listekeyword): self
  209.     {
  210.         $this->listekeywords->removeElement($listekeyword);
  211.         return $this;
  212.     }
  213.     public function getChapo(): ?string
  214.     {
  215.         return $this->chapo;
  216.     }
  217.     public function setChapo(string $chapo): self
  218.     {
  219.         $this->chapo $chapo;
  220.         return $this;
  221.     }
  222.     public function getPinned()
  223.     {
  224.         return $this->pinned;
  225.     }
  226.     public function setPinned($pinned)
  227.     {
  228.         $this->pinned $pinned;
  229.         return $this;
  230.     }
  231. }