| 1 |
<?php |
| 2 |
/** |
| 3 |
* FormFactory.php |
| 4 |
* |
| 5 |
* The FormFactory 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 |
namespace UserAccessManager\Form; |
| 16 |
|
| 17 |
/** |
| 18 |
* Class FormFactory |
| 19 |
* |
| 20 |
* @package UserAccessManager\Form |
| 21 |
*/ |
| 22 |
class FormFactory |
| 23 |
{ |
| 24 |
/** |
| 25 |
* Creates a form object. |
| 26 |
* |
| 27 |
* @return Form |
| 28 |
*/ |
| 29 |
public function createFrom() |
| 30 |
{ |
| 31 |
return new Form(); |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* Creates a ValueSetFormElementValue object. |
| 36 |
* |
| 37 |
* @param mixed $value |
| 38 |
* @param string $label |
| 39 |
* |
| 40 |
* @return ValueSetFormElementValue |
| 41 |
*/ |
| 42 |
public function createValueSetFromElementValue($value, $label) |
| 43 |
{ |
| 44 |
return new ValueSetFormElementValue($value, $label); |
| 45 |
} |
| 46 |
|
| 47 |
/** |
| 48 |
* Creates a MultipleFormElementValue object. |
| 49 |
* |
| 50 |
* @param mixed $value |
| 51 |
* @param string $label |
| 52 |
* |
| 53 |
* @return MultipleFormElementValue |
| 54 |
*/ |
| 55 |
public function createMultipleFormElementValue($value, $label) |
| 56 |
{ |
| 57 |
return new MultipleFormElementValue($value, $label); |
| 58 |
} |
| 59 |
|
| 60 |
/** |
| 61 |
* Creates a Input object. |
| 62 |
* |
| 63 |
* @param string $id |
| 64 |
* @param null|mixed $value |
| 65 |
* @param null|string $label |
| 66 |
* @param null|string $description |
| 67 |
* |
| 68 |
* @return Input |
| 69 |
*/ |
| 70 |
public function createInput($id, $value = null, $label = null, $description = null) |
| 71 |
{ |
| 72 |
return new Input($id, $value, $label, $description); |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Creates a Textarea object. |
| 77 |
* |
| 78 |
* @param string $id |
| 79 |
* @param null|mixed $value |
| 80 |
* @param null|string $label |
| 81 |
* @param null|string $description |
| 82 |
* |
| 83 |
* @return Textarea |
| 84 |
*/ |
| 85 |
public function createTextarea($id, $value = null, $label = null, $description = null) |
| 86 |
{ |
| 87 |
return new Textarea($id, $value, $label, $description); |
| 88 |
} |
| 89 |
|
| 90 |
/** |
| 91 |
* Creates a Select object. |
| 92 |
* |
| 93 |
* @param string $id |
| 94 |
* @param ValueSetFormElementValue[] $possibleValues |
| 95 |
* @param null|mixed $value |
| 96 |
* @param null|string $label |
| 97 |
* @param null|string $description |
| 98 |
* |
| 99 |
* @return Select |
| 100 |
*/ |
| 101 |
public function createSelect($id, array $possibleValues, $value = null, $label = null, $description = null) |
| 102 |
{ |
| 103 |
return new Select($id, $possibleValues, $value, $label, $description); |
| 104 |
} |
| 105 |
|
| 106 |
/** |
| 107 |
* Creates a Radio object. |
| 108 |
* |
| 109 |
* @param string $id |
| 110 |
* @param MultipleFormElementValue[] $possibleValues |
| 111 |
* @param null|mixed $value |
| 112 |
* @param null|string $label |
| 113 |
* @param null|string $description |
| 114 |
* |
| 115 |
* @return Radio |
| 116 |
*/ |
| 117 |
public function createRadio($id, array $possibleValues, $value = null, $label = null, $description = null) |
| 118 |
{ |
| 119 |
return new Radio($id, $possibleValues, $value, $label, $description); |
| 120 |
} |
| 121 |
} |
| 122 |
|