src/Entity/Presse.php line 26

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\PresseRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use App\Utils\Utils;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;  
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Symfony\Component\Validator\Constraints as Assert;   
  10. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  11. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  12. use Symfony\Component\PropertyAccess\PropertyAccess
  13. use Symfony\Component\HttpFoundation\File\File;
  14. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  15. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  16.   
  17. /**
  18.  * @ORM\Entity(repositoryClass=PresseRepository::class)
  19.  * @Vich\Uploadable
  20.  */
  21. class Presse  implements TranslatableInterface
  22.     use TranslatableTrait;
  23.     /**
  24.      * @ORM\Id
  25.      * @ORM\GeneratedValue
  26.      * @ORM\Column(type="integer")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @ORM\Column(type="boolean", nullable=true)
  31.      */
  32.     private $publier;
  33.     /**
  34.      * @ORM\Column(type="date")
  35.      */
  36.     private $datepublication;
  37.     /**
  38.      * @ORM\Column(type="string", length=255, nullable=true)
  39.      */
  40.     private $image;
  41.     /**
  42.      * @ORM\Column(type="string", length=255, nullable=true)
  43.      */
  44.     private $link;
  45.     /**
  46.      * @ORM\Column(type="string", length=255, nullable=true)
  47.      */
  48.     private $fichier;
  49.  
  50.     /**
  51.      * @Gedmo\Timestampable(on="create")
  52.      * @ORM\Column(type="datetime", nullable=true)
  53.      */
  54.     private $created_at;
  55.     /**
  56.      * @Gedmo\Timestampable(on="update")
  57.      * @ORM\Column(type="datetime", nullable=true)
  58.      */
  59.     private $updated_at;
  60.     /**
  61.      * @Vich\UploadableField(mapping="presse_image", fileNameProperty="image")
  62.      * @var File
  63.      */
  64.     private $imageFile;
  65.     /**
  66.      * @Vich\UploadableField(mapping="presse_fichier", fileNameProperty="fichier")
  67.      * @var File
  68.      */
  69.     private $fichierFile;
  70.       
  71.     /**
  72.      * @ORM\Column(type="string", length=255, nullable=true)
  73.      */
  74.     private $type_publication;
  75.     /**
  76.      * @ORM\Column(type="string", length=255, nullable=true)
  77.      */
  78.     private $type_file;
  79.     
  80.  
  81.     protected $translations;
  82.     public function __construct()
  83.     { 
  84.     }
  85.     public function getId(): ?int
  86.     {
  87.         return $this->id;
  88.     }
  89.     public function getPublier(): ?bool
  90.     {
  91.         return $this->publier;
  92.     }
  93.     public function setPublier(?bool $publier): self
  94.     {
  95.         $this->publier $publier;
  96.         return $this;
  97.     }
  98.     public function getDatepublication(): ?\DateTimeInterface
  99.     {
  100.         return $this->datepublication;
  101.     }
  102.     public function setDatepublication(\DateTimeInterface $datepublication): self
  103.     {
  104.         $this->datepublication $datepublication;
  105.         return $this;
  106.     }
  107.     public function getImage(): ?string
  108.     {
  109.         return $this->image;
  110.     }
  111.     public function setImage(?string $image): self
  112.     {
  113.         $this->image $image;
  114.         return $this;
  115.     }
  116.     public function getLink(): ?string
  117.     {
  118.         return $this->link;
  119.     }
  120.     public function setLink(?string $link): self
  121.     {
  122.         $this->link $link;
  123.         return $this;
  124.     }
  125.     public function getFichier(): ?string
  126.     {
  127.         return $this->fichier;
  128.     }
  129.     public function setFichier(?string $fichier): self
  130.     {
  131.         $this->fichier $fichier;
  132.         return $this;
  133.     }
  134.   
  135.  
  136.     public function getCreatedAt(): ?\DateTimeInterface
  137.     {
  138.         return $this->created_at;
  139.     }
  140.     public function setCreatedAt(?\DateTimeInterface $created_at): self
  141.     {
  142.         $this->created_at $created_at;
  143.         return $this;
  144.     }
  145.     public function getUpdatedAt(): ?\DateTimeInterface
  146.     {
  147.         return $this->updated_at;
  148.     }
  149.     public function setUpdatedAt(?\DateTimeInterface $updated_at): self
  150.     {
  151.         $this->updated_at $updated_at;
  152.         return $this;
  153.     }
  154.     
  155.     
  156.     public function setImageFile(File $image null)
  157.     {
  158.         $this->imageFile $image;
  159.         if ($image) {
  160.             $this->updated_at = new \DateTime('now');
  161.         }
  162.         return $this;
  163.     }
  164.     public function getImageFile()
  165.     {
  166.         return $this->imageFile;
  167.     }
  168.     
  169.     public function setFichierFile(File $image null)
  170.     {
  171.         $this->fichierFile $image;
  172.         if ($image) {
  173.             $this->updated_at = new \DateTime('now');
  174.         }
  175.         return $this;
  176.     }
  177.     public function getFichierFile()
  178.     {
  179.         return $this->fichierFile;
  180.     }
  181.     public function getTypePublication(): ?string
  182.     {
  183.         return $this->type_publication;
  184.     }
  185.     public function setTypePublication(?string $type_publication): self
  186.     {
  187.         $this->type_publication $type_publication;
  188.         return $this;
  189.     }
  190.     public function getTypeFile(): ?string
  191.     {
  192.         return $this->type_file;
  193.     }
  194.     public function setTypeFile(?string $type_file): self
  195.     {
  196.         $this->type_file $type_file;
  197.         return $this;
  198.     } 
  199.     public function getDateFormat($local="fr"){
  200.         return Utils::getDateFormating($this->datepublication->format('Y-m-d'),$local);
  201.     }
  202.     public function getDateFormatYear()
  203.     {
  204.         return $this->datepublication->format('Y');
  205.     }
  206.     public function __call($method$arguments)
  207.     {
  208.         return PropertyAccess::createPropertyAccessor()->getValue($this->translate(), $method);
  209.     }
  210. }