Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / auth / CreateFromLoginAuthenticationRequest.php
blobddeb13d9d6f54aed06714e5b7f625fd7cfee6abc
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 /**
25 * This transfers state between the login and account creation flows.
27 * AuthManager::getAuthenticationRequests() won't return this type, but it
28 * may be passed to AuthManager::beginAuthentication() or
29 * AuthManager::beginAccountCreation() anyway.
31 * @ingroup Auth
32 * @since 1.27
34 class CreateFromLoginAuthenticationRequest extends AuthenticationRequest {
35 public $required = self::OPTIONAL;
37 /** @var AuthenticationRequest|null */
38 public $createRequest;
40 /** @var AuthenticationRequest[] */
41 public $maybeLink = [];
43 /**
44 * @param AuthenticationRequest|null $createRequest A request to use to
45 * begin creating the account
46 * @param AuthenticationRequest[] $maybeLink Additional accounts to link
47 * after creation.
49 public function __construct(
50 AuthenticationRequest $createRequest = null, array $maybeLink = []
51 ) {
52 $this->createRequest = $createRequest;
53 $this->maybeLink = $maybeLink;
54 $this->username = $createRequest ? $createRequest->username : null;
57 public function getFieldInfo() {
58 return [];
61 public function loadFromSubmission( array $data ) {
62 return true;
65 /**
66 * Indicate whether this request contains any state for the specified
67 * action.
68 * @param string $action One of the AuthManager::ACTION_* constants
69 * @return boolean
71 public function hasStateForAction( $action ) {
72 switch ( $action ) {
73 case AuthManager::ACTION_LOGIN:
74 return (bool)$this->maybeLink;
75 case AuthManager::ACTION_CREATE:
76 return $this->maybeLink || $this->createRequest;
77 default:
78 return false;
82 /**
83 * Indicate whether this request contains state for the specified
84 * action sufficient to replace other primary-required requests.
85 * @param string $action One of the AuthManager::ACTION_* constants
86 * @return boolean
88 public function hasPrimaryStateForAction( $action ) {
89 switch ( $action ) {
90 case AuthManager::ACTION_CREATE:
91 return (bool)$this->createRequest;
92 default:
93 return false;