oliverde8 /
comfyBundle
| 1 | <?php |
||
| 2 | |||
| 3 | |||
| 4 | namespace oliverde8\ComfyBundle\Model; |
||
| 5 | |||
| 6 | |||
| 7 | use oliverde8\ComfyBundle\Manager\ConfigManagerInterface; |
||
| 8 | use Symfony\Component\Validator\Validator\ValidatorInterface; |
||
| 9 | |||
| 10 | class SelectConfig extends TextConfig |
||
| 11 | { |
||
| 12 | /** @var string[] */ |
||
| 13 | protected $options = []; |
||
| 14 | |||
| 15 | /** @var boolean */ |
||
| 16 | protected $allowMultiple; |
||
| 17 | |||
| 18 | public function __construct( |
||
| 19 | ConfigManagerInterface $configManager, |
||
| 20 | ValidatorInterface $validator, |
||
| 21 | string $path, |
||
| 22 | string $name, |
||
| 23 | string $description = "", |
||
| 24 | int $scope = PHP_INT_MAX, |
||
| 25 | ?string $defaultValue = null, |
||
| 26 | bool $isHidden = false, |
||
| 27 | $options = [], |
||
| 28 | $allowMultiple = false |
||
| 29 | ) { |
||
| 30 | parent::__construct($configManager, $validator, $path, $name, $description, $scope, $defaultValue, $isHidden); |
||
| 31 | |||
| 32 | $this->options = $options; |
||
| 33 | $this->allowMultiple = $allowMultiple; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * Serialize value to save it in Database. |
||
| 38 | * |
||
| 39 | * @param $value |
||
| 40 | * |
||
| 41 | * @return string|null |
||
| 42 | */ |
||
| 43 | protected function serialize($value): ?string |
||
| 44 | { |
||
| 45 | return json_encode($value); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * Deserialize value read from database. |
||
| 50 | * |
||
| 51 | * @param string|null $value |
||
| 52 | * |
||
| 53 | * @return mixed|null |
||
| 54 | */ |
||
| 55 | protected function deserialize(?string $value) |
||
| 56 | { |
||
| 57 | return json_decode($value); |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return string[] |
||
| 62 | */ |
||
| 63 | public function getOptions() |
||
| 64 | { |
||
| 65 | return $this->options; |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * @return bool |
||
| 70 | */ |
||
| 71 | public function isAllowMultiple() |
||
| 72 | { |
||
| 73 | return $this->allowMultiple; |
||
| 74 | } |
||
| 75 | |||
| 76 | |||
| 77 | } |
||
| 78 |