MediaWiki  REL1_31
ButtonAuthenticationRequest.php
Go to the documentation of this file.
1 <?php
22 namespace MediaWiki\Auth;
23 
24 use Message;
25 
33  protected $name;
34 
36  protected $label;
37 
39  protected $help;
40 
47  public function __construct( $name, Message $label, Message $help, $required = false ) {
48  $this->name = $name;
49  $this->label = $label;
50  $this->help = $help;
51  $this->required = $required ? self::REQUIRED : self::OPTIONAL;
52  }
53 
54  public function getUniqueId() {
55  return parent::getUniqueId() . ':' . $this->name;
56  }
57 
58  public function getFieldInfo() {
59  return [
60  $this->name => [
61  'type' => 'button',
62  'label' => $this->label,
63  'help' => $this->help,
64  ]
65  ];
66  }
67 
75  public static function getRequestByName( array $reqs, $name ) {
76  $requests = array_filter( $reqs, function ( $req ) use ( $name ) {
77  return $req instanceof ButtonAuthenticationRequest && $req->name === $name;
78  } );
79  return count( $requests ) === 1 ? reset( $requests ) : null;
80  }
81 
87  public static function __set_state( $data ) {
88  if ( !isset( $data['label'] ) ) {
89  $data['label'] = new \RawMessage( '$1', $data['name'] );
90  } elseif ( is_string( $data['label'] ) ) {
91  $data['label'] = new \Message( $data['label'] );
92  } elseif ( is_array( $data['label'] ) ) {
93  $data['label'] = call_user_func_array( 'Message::newFromKey', $data['label'] );
94  }
95  if ( !isset( $data['help'] ) ) {
96  $data['help'] = new \RawMessage( '$1', $data['name'] );
97  } elseif ( is_string( $data['help'] ) ) {
98  $data['help'] = new \Message( $data['help'] );
99  } elseif ( is_array( $data['help'] ) ) {
100  $data['help'] = call_user_func_array( 'Message::newFromKey', $data['help'] );
101  }
102  $ret = new static( $data['name'], $data['label'], $data['help'] );
103  foreach ( $data as $k => $v ) {
104  $ret->$k = $v;
105  }
106  return $ret;
107  }
108 }
MediaWiki\Auth\ButtonAuthenticationRequest\$name
string $name
Definition: ButtonAuthenticationRequest.php:33
MediaWiki\Auth\AuthenticationRequest\OPTIONAL
const OPTIONAL
Indicates that the request is not required for authentication to proceed.
Definition: AuthenticationRequest.php:40
use
Apache License January AND DISTRIBUTION Definitions License shall mean the terms and conditions for use
Definition: APACHE-LICENSE-2.0.txt:10
array
the array() calling protocol came about after MediaWiki 1.4rc1.
MediaWiki\Auth\AuthenticationRequest\$required
int $required
For login, continue, and link actions, one of self::OPTIONAL, self::REQUIRED, or self::PRIMARY_REQUIR...
Definition: AuthenticationRequest.php:61
$ret
null means default in associative array with keys and values unescaped Should be merged with default with a value of false meaning to suppress the attribute in associative array with keys and values unescaped noclasses & $ret
Definition: hooks.txt:2005
MediaWiki\Auth\ButtonAuthenticationRequest\$label
Message $label
Definition: ButtonAuthenticationRequest.php:36
MediaWiki\Auth\ButtonAuthenticationRequest\$help
Message $help
Definition: ButtonAuthenticationRequest.php:39
php
injection txt This is an overview of how MediaWiki makes use of dependency injection The design described here grew from the discussion of RFC T384 The term dependency this means that anything an object needs to operate should be injected from the the object itself should only know narrow no concrete implementation of the logic it relies on The requirement to inject everything typically results in an architecture that based on two main types of and essentially stateless service objects that use other service objects to operate on the value objects As of the beginning MediaWiki is only starting to use the DI approach Much of the code still relies on global state or direct resulting in a highly cyclical dependency which acts as the top level factory for services in MediaWiki which can be used to gain access to default instances of various services MediaWikiServices however also allows new services to be defined and default services to be redefined Services are defined or redefined by providing a callback the instantiator that will return a new instance of the service When it will create an instance of MediaWikiServices and populate it with the services defined in the files listed by thereby bootstrapping the DI framework Per $wgServiceWiringFiles lists includes ServiceWiring php
Definition: injection.txt:37
MediaWiki\Auth\ButtonAuthenticationRequest\__construct
__construct( $name, Message $label, Message $help, $required=false)
Definition: ButtonAuthenticationRequest.php:47
MediaWiki\Auth\ButtonAuthenticationRequest\getFieldInfo
getFieldInfo()
Fetch input field info.
Definition: ButtonAuthenticationRequest.php:58
MediaWiki\Auth\ButtonAuthenticationRequest\getRequestByName
static getRequestByName(array $reqs, $name)
Fetch a ButtonAuthenticationRequest or subclass by name.
Definition: ButtonAuthenticationRequest.php:75
$requests
Allows to change the fields on the form that will be generated are created Can be used to omit specific feeds from being outputted You must not use this hook to add use OutputPage::addFeedLink() instead. & $feedLinks hooks can tweak the array to change how login etc forms should look $requests
Definition: hooks.txt:304
MediaWiki\Auth\ButtonAuthenticationRequest\__set_state
static __set_state( $data)
Definition: ButtonAuthenticationRequest.php:87
$req
this hook is for auditing only $req
Definition: hooks.txt:990
MediaWiki\Auth\ButtonAuthenticationRequest
This is an authentication request that just implements a simple button.
Definition: ButtonAuthenticationRequest.php:31
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:22
Message
The Message class provides methods which fulfil two basic services:
Definition: Message.php:159
name
design txt This is a brief overview of the new design More thorough and up to date information is available on the documentation wiki at name
Definition: design.txt:12
MediaWiki\Auth
Definition: AbstractAuthenticationProvider.php:22
MediaWiki\Auth\AuthenticationRequest
This is a value object for authentication requests.
Definition: AuthenticationRequest.php:37
MediaWiki\Auth\AuthenticationRequest\REQUIRED
const REQUIRED
Indicates that the request is required for authentication to proceed.
Definition: AuthenticationRequest.php:46
MediaWiki\Auth\ButtonAuthenticationRequest\getUniqueId
getUniqueId()
Supply a unique key for deduplication.
Definition: ButtonAuthenticationRequest.php:54