Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 5
CRAP
0.00% covered (danger)
0.00%
0 / 1
InvalidTopicUuidException
0.00% covered (danger)
0.00%
0 / 11
0.00% covered (danger)
0.00%
0 / 5
56
0.00% covered (danger)
0.00%
0 / 1
 __construct
0.00% covered (danger)
0.00%
0 / 2
0.00% covered (danger)
0.00%
0 / 1
2
 getErrorCodeList
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getHTML
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getPageTitle
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 report
0.00% covered (danger)
0.00%
0 / 6
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3namespace Flow\Exception;
4
5use ErrorPageError;
6use MediaWiki\Title\Title;
7
8/**
9 * Specific exception thrown when a page within NS_TOPIC is requested
10 * through WorkflowLoaderFactory and it is an invalid uuid
11 */
12class InvalidTopicUuidException extends InvalidInputException {
13
14    private ?string $invalidTopic;
15
16    public function __construct( string $message = '', string $code = 'default', ?string $invalidTopic = null ) {
17        parent::__construct( $message, $code );
18        $this->invalidTopic = $invalidTopic;
19    }
20
21    protected function getErrorCodeList() {
22        // flow-error-invalid-input
23        return [ 'invalid-input' ];
24    }
25
26    public function getHTML() {
27        return wfMessage( 'flow-error-invalid-topic-uuid' )->escaped();
28    }
29
30    public function getPageTitle() {
31        return wfMessage( 'flow-error-invalid-topic-uuid-title' )->text();
32    }
33
34    public function report( $action = ErrorPageError::SEND_OUTPUT ) {
35        parent::report( $action );
36
37        if ( $this->invalidTopic !== null && str_ends_with( $this->invalidTopic, '/' ) ) {
38            global $wgOut;
39            $maybeCorrectTitle = Title::newFromText( rtrim( $this->invalidTopic, '/' ), NS_TOPIC );
40            $wgOut->addHTML( wfMessage( 'flow-invalid-topic-did-you-mean', $maybeCorrectTitle->getPrefixedText() ) );
41        }
42    }
43}