Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 1 |
| Hooks | |
0.00% |
0 / 5 |
|
0.00% |
0 / 2 |
20 | |
0.00% |
0 / 1 |
| onAuthChangeFormFields | |
0.00% |
0 / 3 |
|
0.00% |
0 / 1 |
12 | |||
| onAuthPreserveQueryParams | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace MediaWiki\Extension\Campaigns; |
| 4 | |
| 5 | use MediaWiki\Auth\Hook\AuthPreserveQueryParamsHook; |
| 6 | use MediaWiki\Context\RequestContext; |
| 7 | use MediaWiki\SpecialPage\Hook\AuthChangeFormFieldsHook; |
| 8 | |
| 9 | class Hooks implements |
| 10 | AuthChangeFormFieldsHook, |
| 11 | AuthPreserveQueryParamsHook |
| 12 | { |
| 13 | /** @inheritDoc */ |
| 14 | public function onAuthChangeFormFields( |
| 15 | $requests, $fieldInfo, &$formDescriptor, $action |
| 16 | ) { |
| 17 | if ( isset( $formDescriptor['createOrLogin'] ) ) { |
| 18 | $formDescriptor['createOrLogin']['linkQuery'] .= |
| 19 | ( $formDescriptor['createOrLogin']['linkQuery'] ? '&' : '' ) . 'campaign=loginCTA'; |
| 20 | } |
| 21 | } |
| 22 | |
| 23 | /** @inheritDoc */ |
| 24 | public function onAuthPreserveQueryParams( array &$params, array $options ) { |
| 25 | $request = RequestContext::getMain()->getRequest(); |
| 26 | $params['campaign'] = $request->getRawVal( 'campaign' ); |
| 27 | } |
| 28 | } |