Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / auth / ConfirmLinkAuthenticationRequest.php
blobd221eb9fc7f5f3da712a85867551fcb06d38dfd0
1 <?php
2 /**
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
16 * http://www.gnu.org/copyleft/gpl.html
18 * @file
19 * @ingroup Auth
22 namespace MediaWiki\Auth;
24 use InvalidArgumentException;
26 /**
27 * @stable to extend
29 class ConfirmLinkAuthenticationRequest extends AuthenticationRequest {
30 /** @var AuthenticationRequest[] */
31 protected $linkRequests;
33 /** @var string[] List of unique IDs of the confirmed accounts. */
34 public $confirmedLinkIDs = [];
36 /**
37 * @stable to call
38 * @param AuthenticationRequest[] $linkRequests A list of autolink requests
39 * which need to be confirmed.
41 public function __construct( array $linkRequests ) {
42 if ( !$linkRequests ) {
43 throw new InvalidArgumentException( '$linkRequests must not be empty' );
45 $this->linkRequests = $linkRequests;
48 /**
49 * @inheritDoc
50 * @stable to override
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()
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,
72 /**
73 * @inheritDoc
74 * @stable to override
76 public function getUniqueId() {
77 $ids = [];
78 foreach ( $this->linkRequests as $req ) {
79 $ids[] = $req->getUniqueId();
81 return parent::getUniqueId() . ':' . implode( '|', $ids );
84 /**
85 * Implementing this mainly for use from the unit tests.
86 * @param array $data
87 * @return AuthenticationRequest
89 public static function __set_state( $data ) {
90 $ret = new static( $data['linkRequests'] );
91 foreach ( $data as $k => $v ) {
92 $ret->$k = $v;
94 return $ret;