src/Entity/Produit/Service/Imgarticle.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Produit\Service;
  3. use App\Repository\Produit\Service\ImgarticleRepository;
  4. use Symfony\Component\HttpFoundation\File\File;
  5. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. use Doctrine\ORM\Mapping as ORM;
  8. /**
  9.  * @ORM\Table(name="`imgarticle`")
  10.  * @ORM\Entity(repositoryClass=ImgarticleRepository::class)
  11.  * @Vich\Uploadable
  12.  */
  13. class Imgarticle
  14. {
  15.     /**
  16.      * @ORM\Id
  17.      * @ORM\GeneratedValue
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255, nullable=true)
  23.      */
  24.     public $contentUrl;
  25.     /**
  26.      * @ORM\Column(type="string", length=255, nullable=true)
  27.      */
  28.     private $filePath;
  29.     /**
  30.      * @Vich\UploadableField(mapping="filearticle", fileNameProperty="filePath", size="imageSize", mimeType="mimeType", originalName="originalName")
  31.      * @var File|null
  32.      */
  33.     public ?File $file null;
  34.     /**
  35.      * @ORM\Column(type="string", length=255, nullable=true)
  36.      */
  37.     private $imageSize;
  38.     /**
  39.      * @ORM\Column(type="string", length=255, nullable=true)
  40.      */
  41.     private $originalName;
  42.     /**
  43.      * @ORM\Column(type="datetime")
  44.      */
  45.     private $date;
  46.     /**
  47.      * @ORM\Column(type="string", length=255)
  48.      */
  49.     private $mimeType;
  50.     public function __construct()
  51.     {
  52.       $this->date = new \Datetime();
  53.     }
  54.     public function getId(): ?int
  55.     {
  56.         return $this->id;
  57.     }
  58.     public function getClientExtension()
  59.     {
  60.         $tabextension explode('.'$this->getOriginalName());
  61.         $nbelem count($tabextension);
  62.         if($nbelem 1)
  63.         {
  64.             return $tabextension[$nbelem 1];
  65.         }else{
  66.             return "";
  67.         }
  68.     }
  69.     public function getTimeOfSendingFiles(): string
  70.     {
  71.         if($this->date != null)
  72.         {
  73.             return $this->date->format('Y-m-d H:i:s');
  74.         }else{
  75.             return "0000-00-00 00:00:00";
  76.         }
  77.     }
  78.     public function getContentUrl(): ?string
  79.     {
  80.         return $this->contentUrl;
  81.     }
  82.     public function setContentUrl(?string $contentUrl): self
  83.     {
  84.         $this->contentUrl $contentUrl;
  85.         return $this;
  86.     }
  87.     public function getFilePath(): ?string
  88.     {
  89.         return $this->filePath;
  90.     }
  91.     public function setFilePath(?string $filePath): self
  92.     {
  93.         $this->filePath $filePath;
  94.         return $this;
  95.     }
  96.     public function getImageSize(): ?string
  97.     {
  98.         return $this->imageSize;
  99.     }
  100.     public function setImageSize(?string $imageSize): self
  101.     {
  102.         $this->imageSize $imageSize;
  103.         return $this;
  104.     }
  105.     public function getOriginalName(): ?string
  106.     {
  107.         return $this->originalName;
  108.     }
  109.     public function setOriginalName(?string $originalName): self
  110.     {
  111.         $this->originalName $originalName;
  112.         return $this;
  113.     }
  114.     public function getDate(): ?\DateTimeInterface
  115.     {
  116.         return $this->date;
  117.     }
  118.     public function setDate(\DateTimeInterface $date): self
  119.     {
  120.         $this->date $date;
  121.         return $this;
  122.     }
  123.     public function getMimeType(): ?string
  124.     {
  125.         return $this->mimeType;
  126.     }
  127.     public function setMimeType(string $mimeType): self
  128.     {
  129.         $this->mimeType $mimeType;
  130.         return $this;
  131.     }
  132. }