Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 15 |
|
0.00% |
0 / 5 |
CRAP | |
0.00% |
0 / 1 |
| InvalidTopicUuidException | |
0.00% |
0 / 15 |
|
0.00% |
0 / 5 |
72 | |
0.00% |
0 / 1 |
| __construct | |
0.00% |
0 / 2 |
|
0.00% |
0 / 1 |
2 | |||
| getErrorCodeList | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getHTML | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getPageTitle | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| report | |
0.00% |
0 / 10 |
|
0.00% |
0 / 1 |
20 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Flow\Exception; |
| 4 | |
| 5 | use MediaWiki\Exception\ErrorPageError; |
| 6 | use 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 | */ |
| 12 | class 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 | if ( $maybeCorrectTitle ) { |
| 41 | $wgOut->addHTML( wfMessage( |
| 42 | 'flow-invalid-topic-did-you-mean', |
| 43 | $maybeCorrectTitle->getPrefixedText() |
| 44 | ) ); |
| 45 | } |
| 46 | } |
| 47 | } |
| 48 | } |