MediaWiki REL1_37
ConfirmLinkAuthenticationRequest.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Auth;
23
29 protected $linkRequests;
30
32 public $confirmedLinkIDs = [];
33
39 public function __construct( array $linkRequests ) {
40 if ( !$linkRequests ) {
41 throw new \InvalidArgumentException( '$linkRequests must not be empty' );
42 }
43 $this->linkRequests = $linkRequests;
44 }
45
50 public function getFieldInfo() {
51 $options = [];
52 foreach ( $this->linkRequests as $req ) {
53 $description = $req->describeCredentials();
54 $options[$req->getUniqueId()] = wfMessage(
55 'authprovider-confirmlink-option',
56 $description['provider']->text(), $description['account']->text()
57 );
58 }
59 return [
60 'confirmedLinkIDs' => [
61 'type' => 'multiselect',
62 'options' => $options,
63 'label' => wfMessage( 'authprovider-confirmlink-request-label' ),
64 'help' => wfMessage( 'authprovider-confirmlink-request-help' ),
65 'optional' => true,
66 ]
67 ];
68 }
69
74 public function getUniqueId() {
75 $ids = [];
76 foreach ( $this->linkRequests as $req ) {
77 $ids[] = $req->getUniqueId();
78 }
79 return parent::getUniqueId() . ':' . implode( '|', $ids );
80 }
81
87 public static function __set_state( $data ) {
88 $ret = new static( $data['linkRequests'] );
89 foreach ( $data as $k => $v ) {
90 $ret->$k = $v;
91 }
92 return $ret;
93 }
94}
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
This is a value object for authentication requests.
getUniqueId()
Supply a unique key for deduplication.When the AuthenticationRequests instances returned by the provi...
getFieldInfo()
Fetch input field info.The field info is an associative array mapping field names to info arrays....
static __set_state( $data)
Implementing this mainly for use from the unit tests.
string[] $confirmedLinkIDs
List of unique IDs of the confirmed accounts.