src/Entity/Articles/Image.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Articles;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * Image
  7.  *
  8.  * @ORM\Table("article__image")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Articles\ImageRepository")
  10.  */
  11. class Image
  12. {
  13.     /**
  14.      * @ORM\Column(name="id", type="integer")
  15.      * @ORM\Id
  16.      * @ORM\GeneratedValue(strategy="AUTO")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @var integer
  21.      *
  22.      * @ORM\Column(name="id_prestashop", type="string",length=255, nullable=true)
  23.      */
  24.     private $idPrestashop;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity="App\Entity\Articles\Article",inversedBy="images")
  27.      * @ORM\JoinColumn(nullable=false)
  28.      */
  29.     private $article;
  30.     /**
  31.      * @ORM\Column(name="url", type="string", length=255, nullable=true)
  32.      */
  33.     private $url;
  34.     /**
  35.      * @ORM\Column(name="date", type="datetime", nullable=true)
  36.      */
  37.     private $date;
  38.     /**
  39.      * @ORM\Column(name="extension", type="string", length=255, nullable=true)
  40.      */
  41.     private $extension;
  42.     
  43.     /**
  44.      * @ORM\Column(name="position", type="integer", nullable=true)
  45.      */
  46.     private $position;
  47.     /**
  48.      * @ORM\Column(name="affichage_web", type="boolean", nullable=true)
  49.      */
  50.     private $affichageWeb;
  51.     
  52.     /**
  53.      * @ORM\Column(name="id_import", type="string",length=255, nullable=true)
  54.      */
  55.     private $idImport;
  56.     
  57.     /**
  58.      * @ORM\Column(name="id_import_woo", type="string",length=255, nullable=true)
  59.     *
  60.      */
  61.     private $idImportWoo;
  62.     /**
  63.      * @ORM\Column(type="string", length=255, nullable=true)
  64.      */
  65.     private $ulid;     
  66.     
  67.     
  68.     public function __construct()
  69.                       {
  70.                           $this->date = new Datetime();
  71.                          
  72.                       }
  73.     public function getId(): int
  74.     {
  75.         return $this->id;
  76.     }
  77.     public function setUrl(?string $url): Image
  78.     {
  79.         $this->url $url;
  80.         return $this;
  81.     }
  82.     public function getUrl(): ?string
  83.     {
  84.         return $this->url;
  85.     }
  86.     public function setDate(?DateTime $date): Image
  87.     {
  88.         $this->date $date;
  89.         return $this;
  90.     }
  91.     public function getDate(): ?DateTime
  92.     {
  93.         return $this->date;
  94.     }
  95.     public function setExtension(?string $extension): Image
  96.     {
  97.         $this->extension $extension;
  98.         return $this;
  99.     }
  100.     public function getExtension(): ?string
  101.     {
  102.         return $this->extension;
  103.     }
  104.     public function setArticle(?Article $article): Image
  105.     {
  106.         $this->article $article;
  107.         return $this;
  108.     }
  109.     public function getArticle(): ?Article
  110.     {
  111.         return $this->article;
  112.     }
  113.     
  114.      public function getUploadDir() {
  115.         // On retourne le chemin relatif vers l'image pour un navigateur
  116.         //return 'uploads/articles/articles';
  117.         return 'uploads/articles/images/'.$this->getArticle()->getDate()->format("Y").'/'.$this->getArticle()->getDate()->format("m").'/'.$this->getArticle()->getDate()->format("d");
  118.     }
  119.     protected function getUploadRootDir() {
  120.         // On retourne le chemin relatif vers l'image pour notre code PHP
  121.         return __DIR__ '/../../../../web/' $this->getUploadDir();
  122.     }
  123.     public function setPosition(?int $position): Image
  124.     {
  125.         $this->position $position;
  126.         return $this;
  127.     }
  128.     public function getPosition(): ?int
  129.     {
  130.         return $this->position;
  131.     }
  132.     public function setAffichageWeb(?bool $affichageWeb): Image
  133.     {
  134.         $this->affichageWeb $affichageWeb;
  135.         return $this;
  136.     }
  137.     public function getAffichageWeb(): ?bool
  138.     {
  139.         return $this->affichageWeb;
  140.     }
  141.     public function setIdImport(?string $idImport): Image
  142.     {
  143.         $this->idImport $idImport;
  144.         return $this;
  145.     }
  146.     public function getIdImport(): ?string
  147.     {
  148.         return $this->idImport;
  149.     }   
  150.     public function setIdImportWoo(?string $idImportWoo): Image
  151.     {
  152.         $this->idImportWoo $idImportWoo;
  153.         return $this;
  154.     }
  155.     public function getIdImportWoo(): ?string
  156.     {
  157.         return $this->idImportWoo;
  158.     }
  159.     public function getIdPrestashop(): ?string
  160.     {
  161.         return $this->idPrestashop;
  162.     }
  163.     public function setIdPrestashop(?string $idPrestashop): self
  164.     {
  165.         $this->idPrestashop $idPrestashop;
  166.         return $this;
  167.     }
  168.     public function isAffichageWeb(): ?bool
  169.     {
  170.         return $this->affichageWeb;
  171.     }
  172.     public function getUlid(): ?string
  173.     {
  174.         return $this->ulid;
  175.     }
  176.     public function setUlid(?string $ulid): self
  177.     {
  178.         $this->ulid $ulid;
  179.         return $this;
  180.     }    
  181.     
  182.      
  183.     
  184. }