src/Entity/Articles/ArticlesAuthors.php line 24

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Articles;
  3. use Doctrine\DBAL\Types\Types;
  4. use Symfony\Component\Serializer\Annotation\Groups;
  5. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  9. use Symfony\Component\HttpFoundation\File\File;
  10. use App\Repository\Articles\ArticlesAuthorsRepository;
  11. use Symfony\Component\HttpFoundation\File\UploadedFile;
  12. use Vich\UploaderBundle\Entity\File as EmbeddedFile;
  13. /**
  14.  * Articles
  15.  *
  16.  * @ORM\Table("articles_articles_authors")
  17.  * @ORM\Entity(repositoryClass=ArticlesAuthorsRepository::class)
  18.  * @ORM\HasLifecycleCallbacks()
  19.  * @Vich\Uploadable
  20.  */
  21. class ArticlesAuthors {
  22.     /**
  23.      * @var integer
  24.      *
  25.      * @ORM\Column(name="id", type="integer")
  26.      * @ORM\Id
  27.      * @ORM\GeneratedValue(strategy="AUTO")
  28.      * [Groups(['list', 'item'])]
  29.      */
  30.     protected $id;
  31.     /**
  32.      * @var string
  33.      *
  34.      * @ORM\Column(name="created_at", type="datetime", nullable=true, options={"comment":"Date de création"})
  35.      */
  36.     private $createdAt;
  37.     /**
  38.      * @var string
  39.      *
  40.      * @ORM\Column(name="updated_at", type="datetime", nullable=true, options={"comment":"Date de mise à jour"})
  41.      */
  42.     private $updatedAt;
  43.     /**
  44.      * @var string
  45.      *
  46.      * @ORM\Column(name="title", type="string", length=500, nullable=true)
  47.      * [Groups(['list', 'item'])]
  48.      */
  49.     private $title;
  50.     /**
  51.      * @var string
  52.      *
  53.      * @ORM\Column(name="description", type="text", nullable=true)
  54.      * [Groups(['list', 'item'])]
  55.      */
  56.     private $description;
  57.     /**
  58.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  59.      *
  60.      * @Vich\UploadableField(mapping="authors_files", fileNameProperty="image.name", size="image.size", mimeType="image.mimeType", originalName="image.originalName", dimensions="image.dimensions")
  61.      * @Assert\File(
  62.      *     maxSize = "8M",
  63.      *     mimeTypes={"image/jpeg", "image/png", "image/webp"},
  64.      *     mimeTypesMessage = "Please upload a valid PDF or image"
  65.      * )
  66.      * @var File|null
  67.      */
  68.     private $imageFile;
  69.     /**
  70.      * @ORM\Embedded(class="Vich\UploaderBundle\Entity\File")
  71.      *
  72.      * @var EmbeddedFile
  73.      */
  74.     private $image;
  75.     /**
  76.      * @var string
  77.      *
  78.      * @ORM\Column(name="image_alt", type="string", length=500, nullable=true)
  79.      */
  80.     private $imageAlt;
  81.     /**
  82.      * @var string
  83.      *
  84.      * @ORM\Column(name="image_title", type="string", length=500, nullable=true)
  85.      */
  86.     private $imageTitle;
  87.     /**
  88.      * @var string
  89.      *
  90.      * @ORM\Column(name="author", type="string", length=155, nullable=true)
  91.      */
  92.     private $author;
  93.     /**
  94.      * @var string
  95.      *
  96.      * @ORM\Column(name="locale", type="string", length=155, nullable=true)
  97.      */
  98.     private $locale;
  99.     /**
  100.      * @var string
  101.      *
  102.      * @ORM\Column(name="linkedin_url", type="string", length=155, nullable=true)
  103.      */
  104.     private $linkedinUrl;
  105.     public function __construct()
  106.     {
  107.         $this->image = new \Vich\UploaderBundle\Entity\File();
  108.     }
  109.     /**
  110.      * @ORM\PrePersist
  111.      */
  112.     public function setCreatedAtValue(): void
  113.     {
  114.         $this->setCreatedAt(new \DateTime("now"));
  115.         $this->setUpdatedAt(new \DateTime("now"));
  116.     }
  117.     /**
  118.      * @ORM\PreUpdate
  119.      */
  120.     public function setUpdatedAtValue(): void
  121.     {
  122.         $this->setUpdatedAt(new \DateTime("now"));
  123.     }
  124.     public function __toString()
  125.     {
  126.         return $this->title;
  127.     }
  128.     /**
  129.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  130.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  131.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  132.      * must be able to accept an instance of 'File' as the bundle will inject one here
  133.      * during Doctrine hydration.
  134.      *
  135.      * @param File|UploadedFile|null $imageFile
  136.      */
  137.     public function setImageFile(?File $imageFile = null)
  138.     {
  139.         $this->imageFile = $imageFile;
  140.         if (null !== $imageFile) {
  141.             // It is required that at least one field changes if you are using doctrine
  142.             // otherwise the event listeners won't be called and the file is lost
  143.             $this->setUpdatedAt(new \DateTime("now"));
  144.         }
  145.     }
  146.     public function getImageFile(): ?File
  147.     {
  148.         return $this->imageFile;
  149.     }
  150.     public function setImage(EmbeddedFile $image): void
  151.     {
  152.         $this->image = $image;
  153.     }
  154.     public function getImage(): ?EmbeddedFile
  155.     {
  156.         return $this->image;
  157.     }
  158.     public function getId(): ?int
  159.     {
  160.         return $this->id;
  161.     }
  162.     public function getCreatedAt(): ?\DateTimeInterface
  163.     {
  164.         return $this->createdAt;
  165.     }
  166.     public function setCreatedAt(?\DateTimeInterface $createdAt): static
  167.     {
  168.         $this->createdAt = $createdAt;
  169.         return $this;
  170.     }
  171.     public function getUpdatedAt(): ?\DateTimeInterface
  172.     {
  173.         return $this->updatedAt;
  174.     }
  175.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): static
  176.     {
  177.         $this->updatedAt = $updatedAt;
  178.         return $this;
  179.     }
  180.     public function getTitle(): ?string
  181.     {
  182.         return $this->title;
  183.     }
  184.     public function setTitle(?string $title): static
  185.     {
  186.         $this->title = $title;
  187.         return $this;
  188.     }
  189.     public function getDescription(): ?string
  190.     {
  191.         return $this->description;
  192.     }
  193.     public function setDescription(?string $description): static
  194.     {
  195.         $this->description = $description;
  196.         return $this;
  197.     }
  198.     public function getImageAlt(): ?string
  199.     {
  200.         return $this->imageAlt;
  201.     }
  202.     public function setImageAlt(?string $imageAlt): static
  203.     {
  204.         $this->imageAlt = $imageAlt;
  205.         return $this;
  206.     }
  207.     public function getImageTitle(): ?string
  208.     {
  209.         return $this->imageTitle;
  210.     }
  211.     public function setImageTitle(?string $imageTitle): static
  212.     {
  213.         $this->imageTitle = $imageTitle;
  214.         return $this;
  215.     }
  216.     public function getAuthor(): ?string
  217.     {
  218.         return $this->author;
  219.     }
  220.     public function setAuthor(?string $author): static
  221.     {
  222.         $this->author = $author;
  223.         return $this;
  224.     }
  225.     public function getLocale(): ?string
  226.     {
  227.         return $this->locale;
  228.     }
  229.     public function setLocale(?string $locale): static
  230.     {
  231.         $this->locale = $locale;
  232.         return $this;
  233.     }
  234.     public function getLinkedinUrl(): ?string
  235.     {
  236.         return $this->linkedinUrl;
  237.     }
  238.     public function setLinkedinUrl(?string $linkedinUrl): static
  239.     {
  240.         $this->linkedinUrl = $linkedinUrl;
  241.         return $this;
  242.     }
  243. }