You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 satır
2.5KB

  1. <?php
  2. namespace Lc\CaracoleBundle\Model\Merchant;
  3. use Doctrine\ORM\Mapping as ORM;
  4. use Lc\SovBundle\Doctrine\Pattern\AbstractLightEntity;
  5. use Lc\SovBundle\Model\File\FileInterface;
  6. /**
  7. * @ORM\MappedSuperclass()
  8. * @Vich\Uploadable
  9. */
  10. abstract class MerchantConfigModel extends AbstractLightEntity
  11. {
  12. /**
  13. * @ORM\ManyToOne(targetEntity="Lc\CaracoleBundle\Model\Merchant\MerchantInterface", inversedBy="merchantConfigs")
  14. * @ORM\JoinColumn(nullable=false)
  15. */
  16. protected $merchant;
  17. /**
  18. * @ORM\Column(type="string", length=63)
  19. */
  20. protected $name;
  21. /**
  22. * @ORM\Column(type="text", nullable=true)
  23. */
  24. protected $value;
  25. /**
  26. * @ORM\ManyToOne(targetEntity="Lc\SovBundle\Model\File\FileInterface", cascade={"persist", "remove"})
  27. */
  28. protected $image;
  29. public static $availableOptions = [];
  30. public function getMerchant(): ?MerchantInterface
  31. {
  32. return $this->merchant;
  33. }
  34. public function setMerchant(?MerchantInterface $merchant): self
  35. {
  36. $this->merchant = $merchant;
  37. return $this;
  38. }
  39. public function getName(): ?string
  40. {
  41. return $this->name;
  42. }
  43. public function setName(string $name): self
  44. {
  45. $this->name = $name;
  46. return $this;
  47. }
  48. public function getValue(): ?string
  49. {
  50. return $this->value;
  51. }
  52. public function setValue($value): self
  53. {
  54. $this->value = $value;
  55. return $this;
  56. }
  57. public function getImage(): ?FileInterface
  58. {
  59. return $this->image;
  60. }
  61. public function setImage(?FileInterface $image): self
  62. {
  63. $this->image = $image;
  64. return $this;
  65. }
  66. public static function getAvailableOptions(): array
  67. {
  68. return static::$availableOptions;
  69. }
  70. public function getOption()
  71. {
  72. if (isset(static::$availableOptions[$this->getName()])) {
  73. return static::$availableOptions[$this->getName()];
  74. }
  75. return false;
  76. }
  77. public function getOptionValue($key, $default = '')
  78. {
  79. $option = $this->getOption();
  80. if ($option) {
  81. if (isset($option[$key])) {
  82. return $option[$key];
  83. }
  84. }
  85. return $default;
  86. }
  87. public function getLabel()
  88. {
  89. return 'field.MerchantConfig.' . $this->getOptionValue('id');
  90. }
  91. public function getFieldType()
  92. {
  93. return $this->getOptionValue('type', 'text');
  94. }
  95. public function getDefaultValue()
  96. {
  97. return $this->getOptionValue('default');
  98. }
  99. }