Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
WikimediaIncubatorAuthenticationRequest
0.00% covered (danger)
0.00%
0 / 19
0.00% covered (danger)
0.00%
0 / 2
20
0.00% covered (danger)
0.00%
0 / 1
 getFieldInfo
0.00% covered (danger)
0.00%
0 / 15
0.00% covered (danger)
0.00%
0 / 1
2
 loadFromSubmission
0.00% covered (danger)
0.00%
0 / 4
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace MediaWiki\Extension\WikimediaIncubator;
4
5use MediaWiki\Auth\AuthenticationRequest;
6use MediaWiki\Context\RequestContext;
7
8/**
9 * An authentication request to grab the custom fields passed to the creation form.
10 */
11class WikimediaIncubatorAuthenticationRequest extends AuthenticationRequest {
12    /** @var int */
13    public $required = self::OPTIONAL;
14    /** @var string */
15    public $testwikiproject;
16    /** @var string */
17    public $testwikicode;
18
19    /**
20     * @inheritDoc
21     */
22    public function getFieldInfo() {
23        $request = RequestContext::getMain()->getRequest();
24
25        // Accessing $request for the defaults is a bit ugly, but it's what's
26        // needed here.
27        return [
28            'testwikiproject' => [
29                'type' => 'hidden',
30                'value' => strtolower( $request->getVal( 'testwikiproject', '' ) ),
31                'label' => wfMessage( 'wminc-testwiki' ),
32                'help' => wfMessage( 'wminc-prefinfo-project' ),
33            ],
34            'testwikicode' => [
35                'type' => 'hidden',
36                'value' => strtolower( $request->getVal( 'testwikicode', '' ) ),
37                'label' => wfMessage( 'wminc-testwiki-code' ),
38                'help' => wfMessage( 'wminc-prefinfo-code' ),
39            ],
40        ];
41    }
42
43    /** @inheritDoc */
44    public function loadFromSubmission( array $data ) {
45        global $wmincProjects;
46
47        return parent::loadFromSubmission( $data ) &&
48            WikimediaIncubator::validateLanguageCode( $this->testwikicode ) &&
49            isset( $wmincProjects[$this->testwikiproject] );
50    }
51}