|
- <?php
-
- namespace Lc\CaracoleBundle\Model\Merchant;
-
- use Doctrine\ORM\Mapping as ORM;
- use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
- use Lc\SovBundle\Model\File\FileInterface;
-
- /**
- * @ORM\MappedSuperclass()
- * @Vich\Uploadable
- */
- abstract class MerchantConfigModel extends AbstractLightEntity
- {
- /**
- * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="merchantConfigs")
- * @ORM\JoinColumn(nullable=false)
- */
- protected $merchant;
-
- /**
- * @ORM\Column(type="string", length=63)
- */
- protected $name;
-
- /**
- * @ORM\Column(type="text", nullable=true)
- */
- protected $value;
-
- /**
- * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"})
- */
- protected $image;
-
- public static $availableOptions = [];
-
- public function getMerchant(): ?MerchantInterface
- {
- return $this->merchant;
- }
-
- public function setMerchant(?MerchantInterface $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 getImage(): ?FileInterface
- {
- return $this->image;
- }
-
- public function setImage(?FileInterface $image): self
- {
- $this->image = $image;
-
- return $this;
- }
-
- 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');
- }
- }
|