1 | <?php |
||
14 | class ChoiceConfigSetting extends AbstractConfigSetting |
||
15 | { |
||
16 | |||
17 | /** |
||
18 | * Choices. |
||
19 | * |
||
20 | * @var array |
||
21 | */ |
||
22 | private $_choices = array(); |
||
23 | |||
24 | /** |
||
25 | * Creates choice config setting. |
||
26 | * |
||
27 | * @param string $name Name. |
||
28 | * @param array $choices Choices. |
||
29 | * @param mixed $default Default value. |
||
30 | * @param integer $scope_bit Scope. |
||
31 | * |
||
32 | * @throws \InvalidArgumentException When no choices specified. |
||
33 | */ |
||
34 | 32 | public function __construct($name, array $choices, $default, $scope_bit = null) |
|
44 | |||
45 | /** |
||
46 | * Returns choices. |
||
47 | * |
||
48 | * @return array |
||
49 | */ |
||
50 | 1 | public function getChoices() |
|
54 | |||
55 | /** |
||
56 | * Converts value into scalar for used for storage. |
||
57 | * |
||
58 | * @param mixed $value Value. |
||
59 | * |
||
60 | * @return mixed |
||
61 | */ |
||
62 | 29 | protected function convertToStorageFormat($value) |
|
66 | |||
67 | /** |
||
68 | * Performs value validation. |
||
69 | * |
||
70 | * @param mixed $value Value. |
||
71 | * |
||
72 | * @return void |
||
73 | * @throws \InvalidArgumentException When validation failed. |
||
74 | */ |
||
75 | 11 | protected function validate($value) |
|
87 | |||
88 | /** |
||
89 | * Gets choice id from choice itself. |
||
90 | * |
||
91 | * @param mixed $choice Choice. |
||
92 | * |
||
93 | * @return mixed |
||
94 | */ |
||
95 | 29 | protected function getChoiceId($choice) |
|
105 | |||
106 | } |
||
107 |