MediaWiki  master
ConfirmLinkAuthenticationRequest.php
Go to the documentation of this file.
1 <?php
22 namespace 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  $ids = [];
64  foreach ( $this->linkRequests as $req ) {
65  $ids[] = $req->getUniqueId();
66  }
67  return parent::getUniqueId() . ':' . implode( '|', $ids );
68  }
69 
75  public static function __set_state( $data ) {
76  $ret = new static( $data['linkRequests'] );
77  foreach ( $data as $k => $v ) {
78  $ret->$k = $v;
79  }
80  return $ret;
81  }
82 }
MediaWiki\Auth\ConfirmLinkAuthenticationRequest\__construct
__construct(array $linkRequests)
Definition: ConfirmLinkAuthenticationRequest.php:35
wfMessage
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
Definition: GlobalFunctions.php:1222
MediaWiki\Auth\ConfirmLinkAuthenticationRequest\getFieldInfo
getFieldInfo()
Fetch input field info.
Definition: ConfirmLinkAuthenticationRequest.php:42
MediaWiki\Auth\ConfirmLinkAuthenticationRequest\__set_state
static __set_state( $data)
Implementing this mainly for use from the unit tests.
Definition: ConfirmLinkAuthenticationRequest.php:75
MediaWiki\Auth\ConfirmLinkAuthenticationRequest\$linkRequests
AuthenticationRequest[] $linkRequests
Definition: ConfirmLinkAuthenticationRequest.php:26
MediaWiki\Auth\ConfirmLinkAuthenticationRequest\$confirmedLinkIDs
string[] $confirmedLinkIDs
List of unique IDs of the confirmed accounts.
Definition: ConfirmLinkAuthenticationRequest.php:29
MediaWiki\Auth\ConfirmLinkAuthenticationRequest\getUniqueId
getUniqueId()
Supply a unique key for deduplication.
Definition: ConfirmLinkAuthenticationRequest.php:62
MediaWiki\Auth
Definition: AbstractAuthenticationProvider.php:22
MediaWiki\Auth\ConfirmLinkAuthenticationRequest
Definition: ConfirmLinkAuthenticationRequest.php:24
MediaWiki\Auth\AuthenticationRequest
This is a value object for authentication requests.
Definition: AuthenticationRequest.php:37