src/Entity/Gos/Uniqskills/Landing/LandingModuleFile.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Gos\Uniqskills\Landing;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Symfony\Component\HttpFoundation\File\File;
  5. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity()
  9.  * @Vich\Uploadable()
  10.  */
  11. class LandingModuleFile extends LandingModuleItem
  12. {
  13.     /**
  14.      * NOTE: This is not a mapped field of entity metadata, just a simple property.
  15.      *
  16.      * @Assert\File(
  17.      * maxSize="2M"
  18.      * )
  19.      *
  20.      * @Vich\UploadableField(mapping="landing_file", fileNameProperty="variableValue")
  21.      *
  22.      * @var File
  23.      */
  24.     private $file;
  25.     /* ****************************** GETTERS & SETTERS ******************************  */
  26.     /**
  27.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  28.      * of 'UploadedFile' is injected into this setter to trigger the  update. If this
  29.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  30.      * must be able to accept an instance of 'File' as the bundle will inject one here
  31.      * during Doctrine hydration.
  32.      *
  33.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $file
  34.      *
  35.      * @return LandingModuleFile
  36.      */
  37.     public function setFile(File $file null)
  38.     {
  39.         $this->file $file;
  40.         if ($file)
  41.         {
  42.             // It is required that at least one field changes if you are using doctrine
  43.             // otherwise the event listeners won't be called and the file is lost
  44.             $this->updatedAt = new \DateTimeImmutable();
  45.         }
  46.         return $this;
  47.     }
  48.     /**
  49.      * @return File|null
  50.      */
  51.     public function getFile()
  52.     {
  53.         return $this->file;
  54.     }
  55.     /**
  56.      * @param string $variableValue
  57.      *
  58.      * @return LandingModuleFile
  59.      */
  60.     public function setVariableValue($variableValue)
  61.     {
  62.         $this->variableValue $variableValue;
  63.         return $this;
  64.     }
  65.     /**
  66.      * @return string|null
  67.      */
  68.     public function getVariableValue()
  69.     {
  70.         return $this->variableValue;
  71.     }
  72.     /**
  73.      * @return string
  74.      */
  75.     public function getVariableType()
  76.     {
  77.         return $this::VARIABLE_TYPE_FILE;
  78.     }
  79. }