MediaWiki REL1_34
ConfirmLinkAuthenticationRequest.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Auth;
23
26 protected $linkRequests;
27
29 public $confirmedLinkIDs = [];
30
35 public function __construct( array $linkRequests ) {
36 if ( !$linkRequests ) {
37 throw new \InvalidArgumentException( '$linkRequests must not be empty' );
38 }
39 $this->linkRequests = $linkRequests;
40 }
41
42 public function getFieldInfo() {
43 $options = [];
44 foreach ( $this->linkRequests as $req ) {
45 $description = $req->describeCredentials();
46 $options[$req->getUniqueId()] = wfMessage(
47 'authprovider-confirmlink-option',
48 $description['provider']->text(), $description['account']->text()
49 );
50 }
51 return [
52 'confirmedLinkIDs' => [
53 'type' => 'multiselect',
54 'options' => $options,
55 'label' => wfMessage( 'authprovider-confirmlink-request-label' ),
56 'help' => wfMessage( 'authprovider-confirmlink-request-help' ),
57 'optional' => true,
58 ]
59 ];
60 }
61
62 public function getUniqueId() {
63 return parent::getUniqueId() . ':' . implode( '|', array_map( function ( $req ) {
64 return $req->getUniqueId();
66 }
67
73 public static function __set_state( $data ) {
74 $ret = new static( $data['linkRequests'] );
75 foreach ( $data as $k => $v ) {
76 $ret->$k = $v;
77 }
78 return $ret;
79 }
80}
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
This is a value object for authentication requests.
static __set_state( $data)
Implementing this mainly for use from the unit tests.
string[] $confirmedLinkIDs
List of unique IDs of the confirmed accounts.