86 return get_called_class();
152 $fields = array_filter( $this->
getFieldInfo(),
function ( $info ) {
153 return $info[
'type'] !==
'null';
159 foreach ( $fields as $field => $info ) {
164 if ( $info[
'type'] ===
'checkbox' || $info[
'type'] ===
'button' ) {
165 $this->$field = isset( $data[$field] ) && $data[$field] !==
false
166 || isset( $data[
"{$field}_x"] ) && $data[
"{$field}_x"] !==
false;
167 if ( !$this->$field && empty( $info[
'optional'] ) ) {
174 if ( !isset( $data[$field] ) && $info[
'type'] ===
'multiselect' ) {
178 if ( !isset( $data[$field] ) ) {
181 if ( $data[$field] ===
'' || $data[$field] === [] ) {
182 if ( empty( $info[
'optional'] ) ) {
186 switch ( $info[
'type'] ) {
188 if ( !isset( $info[
'options'][$data[$field]] ) ) {
194 $data[$field] = (
array)$data[$field];
195 $allowed = array_keys( $info[
'options'] );
196 if ( array_diff( $data[$field], $allowed ) !== [] ) {
203 $this->$field = $data[$field];
227 'provider' => new \RawMessage(
'$1', [ get_called_class() ] ),
228 'account' => new \RawMessage(
'$1', [ $this->
getUniqueId() ] ),
239 return array_values( array_filter( $reqs,
function (
$req ) use ( $data ) {
240 return $req->loadFromSubmission( $data );
254 $requests = array_filter( $reqs,
function (
$req ) use ( $class, $allowSubclasses ) {
255 if ( $allowSubclasses ) {
256 return is_a(
$req, $class,
false );
258 return get_class(
$req ) === $class;
276 foreach ( $reqs as
$req ) {
277 $info =
$req->getFieldInfo();
278 if ( $info && array_key_exists(
'username', $info ) &&
$req->username !==
null ) {
281 $otherClass = get_class(
$req );
283 $requestClass = get_class(
$req );
284 throw new \UnexpectedValueException(
"Conflicting username fields: \"{$req->username}\" from "
285 .
"$requestClass::\$username vs. \"$username\" from $otherClass::\$username" );
302 $primaryRequests = array_filter( $reqs,
function (
$req ) {
305 $sharedRequiredPrimaryFields = array_reduce( $primaryRequests,
function ( $shared,
$req ) {
307 return empty(
$options[
'optional'] );
309 if ( $shared ===
null ) {
312 return array_intersect( $shared,
$required );
316 foreach ( $reqs as
$req ) {
317 $info =
$req->getFieldInfo();
322 foreach ( $info as $name =>
$options ) {
325 $req->required === self::OPTIONAL
328 ||
$req->required === self::PRIMARY_REQUIRED
329 && !in_array( $name, $sharedRequiredPrimaryFields,
true )
338 if ( !array_key_exists( $name, $merged ) ) {
340 } elseif ( $merged[$name][
'type'] !==
$options[
'type'] ) {
341 throw new \UnexpectedValueException(
"Field type conflict for \"$name\", " .
342 "\"{$merged[$name]['type']}\" vs \"{$options['type']}\""
345 if ( isset(
$options[
'options'] ) ) {
346 if ( isset( $merged[$name][
'options'] ) ) {
374 foreach ( $data as $k => $v ) {
The Message class provides methods which fulfil two basic services:
when a variable name is used in a function
this hook is for auditing only $req
the array() calling protocol came about after MediaWiki 1.4rc1.
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped & $options
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead. & $feedLinks hooks can tweak the array to change how login etc forms should look $requests
Allows to change the fields on the form that will be generated $name