| 1 |
<?php |
| 2 |
/** |
| 3 |
* ValueSetFormElement.php |
| 4 |
* |
| 5 |
* The ValueSetFormElement class file. |
| 6 |
* |
| 7 |
* PHP versions 5 |
| 8 |
* |
| 9 |
* @author Alexander Schneider <alexanderschneider85@gmail.com> |
| 10 |
* @copyright 2008-2017 Alexander Schneider |
| 11 |
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 |
| 12 |
* @version SVN: $id$ |
| 13 |
* @link http://wordpress.org/extend/plugins/user-access-manager/ |
| 14 |
*/ |
| 15 |
|
| 16 |
declare(strict_types=1); |
| 17 |
|
| 18 |
namespace UserAccessManager\Form; |
| 19 |
|
| 20 |
/** |
| 21 |
* Class ValueSetFormElement |
| 22 |
* |
| 23 |
* @package UserAccessManager\Form |
| 24 |
*/ |
| 25 |
abstract class ValueSetFormElement extends FormElement |
| 26 |
{ |
| 27 |
/** |
| 28 |
* @var ValueSetFormElementValue[] |
| 29 |
*/ |
| 30 |
protected $possibleValues; |
| 31 |
|
| 32 |
/** |
| 33 |
* MultipleFormElement constructor. |
| 34 |
* @param string $id |
| 35 |
* @param ValueSetFormElementValue[] $possibleValues |
| 36 |
* @param mixed|null $value |
| 37 |
* @param string|null $label |
| 38 |
* @param string|null $description |
| 39 |
*/ |
| 40 |
public function __construct(string $id, array $possibleValues, $value = null, $label = null, $description = null) |
| 41 |
{ |
| 42 |
parent::__construct($id, $value, $label, $description); |
| 43 |
|
| 44 |
$keys = array_map( |
| 45 |
function (ValueSetFormElementValue $value) { |
| 46 |
return $value->getValue(); |
| 47 |
}, |
| 48 |
$possibleValues |
| 49 |
); |
| 50 |
|
| 51 |
$this->possibleValues = array_combine($keys, $possibleValues); |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* @return ValueSetFormElementValue[] |
| 56 |
*/ |
| 57 |
public function getPossibleValues(): array |
| 58 |
{ |
| 59 |
return $this->possibleValues; |
| 60 |
} |
| 61 |
} |
| 62 |
|