MediaWiki master
ConfirmLinkAuthenticationRequest.php
Go to the documentation of this file.
1<?php
22namespace MediaWiki\Auth;
23
24use InvalidArgumentException;
25
31 protected $linkRequests;
32
34 public $confirmedLinkIDs = [];
35
41 public function __construct( array $linkRequests ) {
42 if ( !$linkRequests ) {
43 throw new InvalidArgumentException( '$linkRequests must not be empty' );
44 }
45 $this->linkRequests = $linkRequests;
46 }
47
52 public function getFieldInfo() {
53 $options = [];
54 foreach ( $this->linkRequests as $req ) {
55 $description = $req->describeCredentials();
56 $options[$req->getUniqueId()] = wfMessage(
57 'authprovider-confirmlink-option',
58 $description['provider']->text(), $description['account']->text()
59 );
60 }
61 return [
62 'confirmedLinkIDs' => [
63 'type' => 'multiselect',
64 'options' => $options,
65 'label' => wfMessage( 'authprovider-confirmlink-request-label' ),
66 'help' => wfMessage( 'authprovider-confirmlink-request-help' ),
67 'optional' => true,
68 ]
69 ];
70 }
71
76 public function getUniqueId() {
77 $ids = [];
78 foreach ( $this->linkRequests as $req ) {
79 $ids[] = $req->getUniqueId();
80 }
81 return parent::getUniqueId() . ':' . implode( '|', $ids );
82 }
83
89 public static function __set_state( $data ) {
90 $ret = new static( $data['linkRequests'] );
91 foreach ( $data as $k => $v ) {
92 $ret->$k = $v;
93 }
94 return $ret;
95 }
96}
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.This will be used in the AuthManager APIs and web UIs to define API input para...
static __set_state( $data)
Implementing this mainly for use from the unit tests.
string[] $confirmedLinkIDs
List of unique IDs of the confirmed accounts.