src/Entity/Media.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use Symfony\Component\HttpFoundation\File\File;
  7. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  8. use Defr\PhpMimeType\MimeType;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. /**
  11.  * @ORM\Entity(repositoryClass="App\Repository\MediaRepository")
  12.  * @Vich\Uploadable
  13.  */
  14. class Media
  15. {
  16.     /**
  17.      * @ORM\Id()
  18.      * @ORM\GeneratedValue()
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @ORM\Column(type="string", length=255)
  24.      */
  25.     private $name;
  26.     /**
  27.      * @return mixed
  28.      */
  29.     public function getName()
  30.     {
  31.         return $this->name;
  32.     }
  33.     /**
  34.      * @param mixed $name
  35.      */
  36.     public function setName($name): void
  37.     {
  38.         $this->name $name;
  39.     }
  40.     /**
  41.      * @Assert\File(
  42.      *     mimeTypes = {"application/pdf", "application/x-pdf", "application/zip", "video/flv", "video/mpeg", "video/mp4"},
  43.      *     mimeTypesMessage = "SVP seuls les fichiers d'extension pdf, flv, mpeg, mp4 et zip  sont requis."
  44.      *
  45.      * )
  46.      * @Vich\UploadableField(mapping="medias", fileNameProperty="name")
  47.      * @var File
  48.      */
  49.     private $namefile;
  50.     /**
  51.      * @Assert\File(
  52.      *     mimeTypes = {"image/png", "image/gif", "image/jpeg", "image/jpg"},
  53.      *     mimeTypesMessage = "SVP seuls les fichiers image d'extension png, gif, jpeg et jpg sont requis."
  54.      *
  55.      * )
  56.      * @Vich\UploadableField(mapping="medias", fileNameProperty="name")
  57.      * @var File
  58.      */
  59.     private $imagefile;
  60.     /**
  61.      * @ORM\Column(type="boolean")
  62.      */
  63.     private $visible;
  64.     /**
  65.      * @ORM\Column(type="datetime")
  66.      */
  67.     private $createAt;
  68.     /**
  69.      * @ORM\Column(type="string", length=255)
  70.      */
  71.     private $title;
  72.     /**
  73.      * @ORM\ManyToOne(targetEntity="App\Entity\TypeDocument", inversedBy="typedocument")
  74.      * @ORM\JoinColumn(nullable=false)
  75.      */
  76.     private $typeDocument;
  77.     /**
  78.      * @ORM\Column(type="text")
  79.      */
  80.     private $description;
  81.     /**
  82.      * @ORM\Column(type="string", length=255)
  83.      */
  84.     private $typefile;
  85.     public function getId(): ?int
  86.     {
  87.         return $this->id;
  88.     }
  89.     /**
  90.      * @return File|null
  91.      */
  92.     public function getNamefile()
  93.     {
  94.         return $this->namefile;
  95.     }
  96.     /**
  97.      * @param File $namefile
  98.      */
  99.     public function setNamefile(File $namefile): void
  100.     {
  101.         $this->namefile $namefile;
  102.     }
  103.     public function getVisible(): ?bool
  104.     {
  105.         return $this->visible;
  106.     }
  107.     public function setVisible(bool $visible): self
  108.     {
  109.         $this->visible $visible;
  110.         return $this;
  111.     }
  112.     public function getCreateAt(): ?\DateTimeInterface
  113.     {
  114.         return $this->createAt;
  115.     }
  116.     public function setCreateAt(\DateTimeInterface $createAt): self
  117.     {
  118.         $this->createAt $createAt;
  119.         return $this;
  120.     }
  121.     /**
  122.      * @return File
  123.      */
  124.     public function getImagefile()
  125.     {
  126.         return $this->imagefile;
  127.     }
  128.     /**
  129.      * @param File $imagefile
  130.      */
  131.     public function setImagefile(File $imagefile): void
  132.     {
  133.         $this->imagefile $imagefile;
  134.     }
  135.     public function getTitle(): ?string
  136.     {
  137.         return $this->title;
  138.     }
  139.     public function setTitle(string $title): self
  140.     {
  141.         $this->title $title;
  142.         return $this;
  143.     }
  144.     /**
  145.      * toString
  146.      *
  147.      * @return string
  148.      */
  149.     public function __toString() {
  150.             return (string) $this->getTitle();
  151.     }
  152.     public function getTypeDocument(): ?TypeDocument
  153.     {
  154.         return $this->typeDocument;
  155.     }
  156.     public function setTypeDocument(?TypeDocument $typeDocument): self
  157.     {
  158.         $this->typeDocument $typeDocument;
  159.         return $this;
  160.     }
  161.     public function getDescription(): ?string
  162.     {
  163.         return $this->description;
  164.     }
  165.     public function setDescription(string $description): self
  166.     {
  167.         $this->description $description;
  168.         return $this;
  169.     }
  170.     public function getTypefile(): ?string
  171.     {
  172.         return $this->typefile;
  173.     }
  174.     public function setTypefile(string $typefile): self
  175.     {
  176.         $this->typefile $typefile;
  177.         return $this;
  178.     }
  179. }