No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

126 líneas
2.4KB

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