<?php
namespace App\Entity\Gos\Uniqskills\Landing;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\HttpFoundation\File\File;
use Vich\UploaderBundle\Mapping\Annotation as Vich;
use Symfony\Component\Validator\Constraints as Assert;
/**
* @ORM\Entity()
* @Vich\Uploadable()
*/
class LandingModuleFile extends LandingModuleItem
{
/**
* NOTE: This is not a mapped field of entity metadata, just a simple property.
*
* @Assert\File(
* maxSize="2M"
* )
*
* @Vich\UploadableField(mapping="landing_file", fileNameProperty="variableValue")
*
* @var File
*/
private $file;
/* ****************************** GETTERS & SETTERS ****************************** */
/**
* If manually uploading a file (i.e. not using Symfony Form) ensure an instance
* of 'UploadedFile' is injected into this setter to trigger the update. If this
* bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
* must be able to accept an instance of 'File' as the bundle will inject one here
* during Doctrine hydration.
*
* @param File|\Symfony\Component\HttpFoundation\File\UploadedFile $file
*
* @return LandingModuleFile
*/
public function setFile(File $file = null)
{
$this->file = $file;
if ($file)
{
// It is required that at least one field changes if you are using doctrine
// otherwise the event listeners won't be called and the file is lost
$this->updatedAt = new \DateTimeImmutable();
}
return $this;
}
/**
* @return File|null
*/
public function getFile()
{
return $this->file;
}
/**
* @param string $variableValue
*
* @return LandingModuleFile
*/
public function setVariableValue($variableValue)
{
$this->variableValue = $variableValue;
return $this;
}
/**
* @return string|null
*/
public function getVariableValue()
{
return $this->variableValue;
}
/**
* @return string
*/
public function getVariableType()
{
return $this::VARIABLE_TYPE_FILE;
}
}