src/Entity/Core/Ebook.php line 22

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Core;
  3. use Doctrine\DBAL\Types\Types;
  4. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  5. use Symfony\Component\Validator\Constraints as Assert;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Symfony\Component\HttpFoundation\File\UploadedFile;
  10. use Vich\UploaderBundle\Entity\File as EmbeddedFile;
  11. /**
  12.  * Ebook
  13.  *
  14.  * @ORM\Table("core_ebook")
  15.  * @ORM\Entity(repositoryClass="App\Repository\Core\EbookRepository")
  16.  * @ORM\HasLifecycleCallbacks()
  17.  * @Vich\Uploadable
  18.  */
  19. class Ebook
  20. {
  21.     /**
  22.      * @var integer
  23.      *
  24.      * @ORM\Column(name="id", type="integer")
  25.      * @ORM\Id
  26.      * @ORM\GeneratedValue(strategy="AUTO")
  27.      */
  28.     protected $id;
  29.     /**
  30.      * @var string
  31.      *
  32.      * @ORM\Column(name="created_at", type="date", nullable=true)
  33.      */
  34.     private $createdAt;
  35.     /**
  36.      * @var string
  37.      *
  38.      * @ORM\Column(name="updated_at", type="date", nullable=true)
  39.      */
  40.     private $updatedAt;
  41.     /**
  42.      * @var string
  43.      *
  44.      * @ORM\Column(name="title", type="string", length=255, nullable=true)
  45.      */
  46.     private $title;
  47.     /**
  48.      * @var string
  49.      *
  50.      * @ORM\Column(name="description", type="text", nullable=true)
  51.      */
  52.     private $description;
  53.     /**
  54.      * @var string
  55.      *
  56.      * @ORM\Column(name="description_form", type="text", nullable=true)
  57.      */
  58.     private $descriptionForm;
  59.     /**
  60.      * @var string
  61.      *
  62.      * @ORM\Column(name="short_title", type="string", length=255, nullable=true)
  63.      */
  64.     private $shortTitle;
  65.     /**
  66.      * @var string
  67.      *
  68.      * @ORM\Column(name="short_description", type="string", length=255, nullable=true)
  69.      */
  70.     private $shortDescription;
  71.     /**
  72.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  73.      *
  74.      * @Vich\UploadableField(mapping="ebooks_files", fileNameProperty="image.name", size="image.size", mimeType="image.mimeType", originalName="image.originalName", dimensions="image.dimensions")
  75.      *
  76.      * @var File|null
  77.      */
  78.     private $imageFile;
  79.     /**
  80.      * @ORM\Embedded(class="Vich\UploaderBundle\Entity\File")
  81.      *
  82.      * @var EmbeddedFile
  83.      */
  84.     private $image;
  85.     /**
  86.      * @var string
  87.      *
  88.      * @ORM\Column(name="html", type="text", nullable=true)
  89.      */
  90.     private $html;
  91.     /**
  92.      * @var string
  93.      *
  94.      * @ORM\Column(name="javascript", type="text", nullable=true)
  95.      */
  96.     private $javascript;
  97.     /**
  98.      * @var string
  99.      *
  100.      * @ORM\Column(name="valide", type="boolean", nullable=true)
  101.      */
  102.     private $valide;
  103.     /**
  104.      * @var string
  105.      *
  106.      * @ORM\Column(name="subtitle", type="text", nullable=true)
  107.      */
  108.     private $subtitle;
  109.     /**
  110.      * @var string
  111.      *
  112.      * @ORM\Column(name="title_download", type="text", nullable=true)
  113.      */
  114.     private $titleDownload;
  115.     /**
  116.      * @var string
  117.      *
  118.      * @ORM\Column(name="description_download", type="text", nullable=true)
  119.      */
  120.     private $descriptionDownload;
  121.     /**
  122.      * @var string
  123.      *
  124.      * @ORM\Column(name="button_download", type="text", nullable=true)
  125.      */
  126.     private $buttonDownload;
  127.     public function __construct()
  128.     {
  129.         $this->image = new \Vich\UploaderBundle\Entity\File();
  130.     }
  131.     /**
  132.      * @ORM\PrePersist
  133.      */
  134.     public function setCreatedAtValue(): void {
  135.         $this->setCreatedAt(new \DateTime("now"));
  136.         $this->setUpdatedAt(new \DateTime("now"));
  137.     }
  138.     /**
  139.      * @ORM\PreUpdate
  140.      */
  141.     public function setUpdatedAtValue(): void {
  142.         $this->setUpdatedAt(new \DateTime("now"));
  143.     }
  144.     public function __toString() {
  145.         return (string)$this->title;
  146.     }
  147.     /**
  148.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  149.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  150.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  151.      * must be able to accept an instance of 'File' as the bundle will inject one here
  152.      * during Doctrine hydration.
  153.      *
  154.      * @param File|UploadedFile|null $imageFile
  155.      */
  156.     public function setImageFile(?File $imageFile null)
  157.     {
  158.         $this->imageFile $imageFile;
  159.         if (null !== $imageFile) {
  160.             // It is required that at least one field changes if you are using doctrine
  161.             // otherwise the event listeners won't be called and the file is lost
  162.             $this->setUpdatedAt(new \DateTime("now"));
  163.         }
  164.     }
  165.     public function getImageFile(): ?File
  166.     {
  167.         return $this->imageFile;
  168.     }
  169.     public function setImage(EmbeddedFile $image): void
  170.     {
  171.         $this->image $image;
  172.     }
  173.     public function getImage(): ?EmbeddedFile
  174.     {
  175.         return $this->image;
  176.     }
  177.     public function getId(): ?int
  178.     {
  179.         return $this->id;
  180.     }
  181.     public function getCreatedAt(): ?\DateTimeInterface
  182.     {
  183.         return $this->createdAt;
  184.     }
  185.     public function setCreatedAt(?\DateTimeInterface $createdAt): self
  186.     {
  187.         $this->createdAt $createdAt;
  188.         return $this;
  189.     }
  190.     public function getUpdatedAt(): ?\DateTimeInterface
  191.     {
  192.         return $this->updatedAt;
  193.     }
  194.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  195.     {
  196.         $this->updatedAt $updatedAt;
  197.         return $this;
  198.     }
  199.     public function getTitle(): ?string
  200.     {
  201.         return $this->title;
  202.     }
  203.     public function setTitle(?string $title): self
  204.     {
  205.         $this->title $title;
  206.         return $this;
  207.     }
  208.     public function getDescription(): ?string
  209.     {
  210.         return $this->description;
  211.     }
  212.     public function setDescription(?string $description): self
  213.     {
  214.         $this->description $description;
  215.         return $this;
  216.     }
  217.     public function getDescriptionForm(): ?string
  218.     {
  219.         return $this->descriptionForm;
  220.     }
  221.     public function setDescriptionForm(?string $descriptionForm): self
  222.     {
  223.         $this->descriptionForm $descriptionForm;
  224.         return $this;
  225.     }
  226.     public function getShortTitle(): ?string
  227.     {
  228.         return $this->shortTitle;
  229.     }
  230.     public function setShortTitle(?string $shortTitle): self
  231.     {
  232.         $this->shortTitle $shortTitle;
  233.         return $this;
  234.     }
  235.     public function getShortDescription(): ?string
  236.     {
  237.         return $this->shortDescription;
  238.     }
  239.     public function setShortDescription(?string $shortDescription): self
  240.     {
  241.         $this->shortDescription $shortDescription;
  242.         return $this;
  243.     }
  244.     public function getHtml(): ?string
  245.     {
  246.         return $this->html;
  247.     }
  248.     public function setHtml(?string $html): self
  249.     {
  250.         $this->html $html;
  251.         return $this;
  252.     }
  253.     public function getValide(): ?bool
  254.     {
  255.         return $this->valide;
  256.     }
  257.     public function setValide(?bool $valide): self
  258.     {
  259.         $this->valide $valide;
  260.         return $this;
  261.     }
  262.     public function getSubtitle(): ?string
  263.     {
  264.         return $this->subtitle;
  265.     }
  266.     public function setSubtitle(?string $subtitle): self
  267.     {
  268.         $this->subtitle $subtitle;
  269.         return $this;
  270.     }
  271.     public function getTitleDownload(): ?string
  272.     {
  273.         return $this->titleDownload;
  274.     }
  275.     public function setTitleDownload(?string $titleDownload): self
  276.     {
  277.         $this->titleDownload $titleDownload;
  278.         return $this;
  279.     }
  280.     public function getDescriptionDownload(): ?string
  281.     {
  282.         return $this->descriptionDownload;
  283.     }
  284.     public function setDescriptionDownload(?string $descriptionDownload): self
  285.     {
  286.         $this->descriptionDownload $descriptionDownload;
  287.         return $this;
  288.     }
  289.     public function getButtonDownload(): ?string
  290.     {
  291.         return $this->buttonDownload;
  292.     }
  293.     public function setButtonDownload(?string $buttonDownload): self
  294.     {
  295.         $this->buttonDownload $buttonDownload;
  296.         return $this;
  297.     }
  298.     public function getjavascript(): ?string
  299.     {
  300.         return $this->javascript;
  301.     }
  302.     public function setJavascript(?string $javascript): self
  303.     {
  304.         $this->javascript $javascript;
  305.         return $this;
  306.     }
  307.     public function isValide(): ?bool
  308.     {
  309.         return $this->valide;
  310.     }
  311. }