Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / auth / PasswordDomainAuthenticationRequest.php
blob561f3772f52c2891d123b2870db931f87f7f77d7
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 MediaWiki\Language\RawMessage;
26 /**
27 * This is a value object for authentication requests with a username, password, and domain
28 * @stable to extend
29 * @ingroup Auth
30 * @since 1.27
32 class PasswordDomainAuthenticationRequest extends PasswordAuthenticationRequest {
33 /** @var string[] Domains available */
34 private $domainList;
36 /** @var string|null */
37 public $domain = null;
39 /**
40 * @stable to call
41 * @param string[] $domainList List of available domains
43 public function __construct( array $domainList ) {
44 $this->domainList = $domainList;
47 /**
48 * @inheritDoc
49 * @stable to override
51 public function getFieldInfo() {
52 $ret = parent::getFieldInfo();
54 // Only add a domain field if we have the username field included
55 if ( isset( $ret['username'] ) ) {
56 $ret['domain'] = [
57 'type' => 'select',
58 'options' => [],
59 'label' => wfMessage( 'yourdomainname' ),
60 'help' => wfMessage( 'authmanager-domain-help' ),
62 foreach ( $this->domainList as $domain ) {
63 $ret['domain']['options'][$domain] = new RawMessage( '$1', [ $domain ] );
67 return $ret;
70 /**
71 * @inheritDoc
72 * @stable to override
74 public function describeCredentials() {
75 return [
76 'provider' => wfMessage( 'authmanager-provider-password-domain' ),
77 'account' => wfMessage(
78 'authmanager-account-password-domain', [ $this->username, $this->domain ]
83 /**
84 * @codeCoverageIgnore
85 * @param array $data
86 * @return AuthenticationRequest|static
88 public static function __set_state( $data ) {
89 $ret = new static( $data['domainList'] );
90 foreach ( $data as $k => $v ) {
91 if ( $k !== 'domainList' ) {
92 $ret->$k = $v;
95 return $ret;