|
- <?php
-
- namespace Lc\ShopBundle\Model;
-
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\HttpFoundation\File\File;
- use Vich\UploaderBundle\Mapping\Annotation as Vich;
-
-
- abstract class MerchantConfig extends AbstractEntity
- {
-
-
- protected $merchant;
-
-
-
- protected $name;
-
-
-
- protected $value;
-
-
-
- protected $imageFile;
-
- public static $availableOptions = [] ;
-
- public function getMerchant(): ?Merchant
- {
- return $this->merchant;
- }
-
- public function setMerchant(?Merchant $merchant): self
- {
- $this->merchant = $merchant;
-
- return $this;
- }
-
- public function getName(): ?string
- {
- return $this->name;
- }
-
- public function setName(string $name): self
- {
- $this->name = $name;
-
- return $this;
- }
-
- public function getValue(): ?string
- {
- return $this->value;
- }
-
- public function setValue($value): self
- {
- $this->value = $value;
-
- return $this;
- }
-
- public function setImageFile(File $image = null)
- {
- $this->imageFile = $image;
-
-
-
-
- if ($image) {
-
- $this->updatedAt = new \DateTime('now');
- }
- }
-
- public function getImageFile()
- {
- return $this->imageFile;
- }
-
- public static function getAvailableOptions(): array
- {
- return static::$availableOptions ;
- }
-
- public function getOption()
- {
- if(isset(static::$availableOptions[$this->getName()])) {
- return static::$availableOptions[$this->getName()] ;
- }
- return false ;
- }
-
- public function getOptionValue($key, $default = '')
- {
- $option = $this->getOption() ;
- if($option) {
- if(isset($option[$key])) {
- return $option[$key] ;
- }
- }
-
- return $default ;
- }
-
- public function getLabel()
- {
- return 'field.MerchantConfig.'.$this->getOptionValue('id') ;
- }
-
- public function getFieldType()
- {
- return $this->getOptionValue('type', 'text') ;
- }
-
- public function getDefaultValue()
- {
- return $this->getOptionValue('default') ;
- }
- }
|