1 | <?php |
||
14 | class ParamDefinitionFactory { |
||
15 | |||
16 | /** |
||
17 | * Maps parameter type to handling IParameterDefinition implementing class. |
||
18 | * |
||
19 | * @since 1.0 |
||
20 | * |
||
21 | * @var array |
||
22 | */ |
||
23 | private $typeToClass = []; |
||
24 | |||
25 | /** |
||
26 | * Maps parameter type to its associated components. |
||
27 | * |
||
28 | * @since 1.0 |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | private $typeToComponent = []; |
||
33 | |||
34 | /** |
||
35 | * Singleton. |
||
36 | * |
||
37 | * @since 1.0 |
||
38 | * @deprecated since 1.0 |
||
39 | * |
||
40 | * @return ParamDefinitionFactory |
||
41 | */ |
||
42 | 64 | public static function singleton() { |
|
52 | |||
53 | /** |
||
54 | * Registers the parameter types specified in the global $wgParamDefinitions. |
||
55 | * |
||
56 | * @since 1.0 |
||
57 | */ |
||
58 | public function registerGlobals() { |
||
69 | |||
70 | /** |
||
71 | * Registers a parameter type. |
||
72 | * |
||
73 | * The type is specified as a string identifier for the type, ie 'boolean', |
||
74 | * and an array containing further data. This data currently includes: |
||
75 | * |
||
76 | * - string-parser: the parser to use to transform string values |
||
77 | * This class needs to implement ValueParser. Default: NullParser |
||
78 | * - typed-parser: the parser to use to transform typed PHP values |
||
79 | * This class needs to implement ValueParser. Default: NullParser |
||
80 | * - validator: the validation object to use |
||
81 | * This class needs to implement ValueValidator. Default: NullValidator |
||
82 | * - validation-callback a callback to use for validation, called before the ValueValidator |
||
83 | * This callback needs to return a boolean indicating validity. |
||
84 | * |
||
85 | * @since 1.0 |
||
86 | * |
||
87 | * @param string $type |
||
88 | * @param array $data |
||
89 | * |
||
90 | * @return boolean Indicates if the type was registered |
||
91 | */ |
||
92 | public function registerType( $type, array $data ) { |
||
115 | |||
116 | /** |
||
117 | * Creates a new instance of a IParamDefinition based on the provided type. |
||
118 | * |
||
119 | * @since 1.0 |
||
120 | * |
||
121 | * @param string $type |
||
122 | * @param string $name |
||
123 | * @param mixed $default |
||
124 | * @param string $message |
||
125 | * @param boolean $isList |
||
126 | * |
||
127 | * @return IParamDefinition |
||
128 | * @throws OutOfBoundsException |
||
129 | */ |
||
130 | 36 | public function newDefinition( $type, $name, $default, $message, $isList = false ) { |
|
162 | |||
163 | /** |
||
164 | * Returns the specified component for the provided parameter type. |
||
165 | * This method is likely to change in the future in a compat breaking way. |
||
166 | * |
||
167 | * @since 1.0 |
||
168 | * |
||
169 | * @param string $paramType |
||
170 | * @param string $componentType |
||
171 | * |
||
172 | * @throws Exception |
||
173 | * @return mixed |
||
174 | */ |
||
175 | 64 | public function getComponentForType( $paramType, $componentType ) { |
|
186 | |||
187 | /** |
||
188 | * Construct a new ParamDefinition from an array. |
||
189 | * |
||
190 | * @since 1.0 |
||
191 | * |
||
192 | * @param array $param |
||
193 | * @param bool $getMad |
||
194 | * |
||
195 | * @return IParamDefinition|false |
||
196 | * @throws Exception |
||
197 | */ |
||
198 | 36 | public function newDefinitionFromArray( array $param, $getMad = true ) { |
|
221 | |||
222 | } |
||
223 |