|
|
@@ -3,11 +3,14 @@ |
|
|
|
namespace Lc\ShopBundle\Model; |
|
|
|
|
|
|
|
use Doctrine\ORM\Mapping as ORM; |
|
|
|
use Symfony\Component\HttpFoundation\File\File; |
|
|
|
use Vich\UploaderBundle\Mapping\Annotation as Vich; |
|
|
|
|
|
|
|
/** |
|
|
|
* @ORM\MappedSuperclass() |
|
|
|
* @Vich\Uploadable |
|
|
|
*/ |
|
|
|
abstract class MerchantConfig |
|
|
|
abstract class MerchantConfig extends AbstractEntity |
|
|
|
{ |
|
|
|
/** |
|
|
|
* @ORM\ManyToOne(targetEntity="Lc\ShopBundle\Context\MerchantInterface", inversedBy="merchantConfigs") |
|
|
@@ -25,6 +28,12 @@ abstract class MerchantConfig |
|
|
|
*/ |
|
|
|
protected $value; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Vich\UploadableField(mapping="images", fileNameProperty="value") |
|
|
|
* @var File |
|
|
|
*/ |
|
|
|
protected $imageFile; |
|
|
|
|
|
|
|
public static $availableOptions = [] ; |
|
|
|
|
|
|
|
public function getMerchant(): ?Merchant |
|
|
@@ -63,6 +72,24 @@ abstract class MerchantConfig |
|
|
|
return $this; |
|
|
|
} |
|
|
|
|
|
|
|
public function setImageFile(File $image = null) |
|
|
|
{ |
|
|
|
$this->imageFile = $image; |
|
|
|
|
|
|
|
// VERY IMPORTANT: |
|
|
|
// 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 |
|
|
|
if ($image) { |
|
|
|
// if 'updatedAt' is not defined in your entity, use another property |
|
|
|
$this->updatedAt = new \DateTime('now'); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public function getImageFile() |
|
|
|
{ |
|
|
|
return $this->imageFile; |
|
|
|
} |
|
|
|
|
|
|
|
public static function getAvailableOptions(): array |
|
|
|
{ |
|
|
|
return static::$availableOptions ; |