| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace UserAccessManager\Form\Element; |
| 6 |
|
| 7 |
use Exception; |
| 8 |
use UserAccessManager\Form\Form; |
| 9 |
|
| 10 |
abstract class MultipleFormElement extends ValueSetFormElement |
| 11 |
{ |
| 12 |
/** |
| 13 |
* @param MultipleFormElementValue[] $possibleValues |
| 14 |
* @throws Exception |
| 15 |
*/ |
| 16 |
public function __construct( |
| 17 |
string $id, |
| 18 |
array $possibleValues, |
| 19 |
mixed $value = null, |
| 20 |
?string $label = null, |
| 21 |
?string $description = null |
| 22 |
) { |
| 23 |
foreach ($possibleValues as $possibleValue) { |
| 24 |
if (!$possibleValue instanceof MultipleFormElementValue) { |
| 25 |
throw new Exception('Values must be MultipleFormElementValue objects'); |
| 26 |
} |
| 27 |
} |
| 28 |
|
| 29 |
parent::__construct($id, $possibleValues, $value, $label, $description); |
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 33 |
* @return MultipleFormElementValue[] |
| 34 |
*/ |
| 35 |
public function getPossibleValues(): array |
| 36 |
{ |
| 37 |
return $this->possibleValues; |
| 38 |
} |
| 39 |
} |
| 40 |
|