MediaWiki master
MalformedTitleException.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Title;
22
23use Exception;
26
32class MalformedTitleException extends Exception implements ILocalizedException {
33
35 private $titleText;
37 private $errorMessage;
39 private $errorMessageParameters;
40
48 public function __construct(
49 $errorMessage, $titleText = null, $errorMessageParameters = []
50 ) {
51 $this->errorMessage = $errorMessage;
52 $this->titleText = $titleText;
53 if ( $titleText !== null ) {
54 $errorMessageParameters[] = wfEscapeWikiText( $titleText );
55 }
56 $this->errorMessageParameters = $errorMessageParameters;
57
58 // Supply something useful for Exception::getMessage() to return.
59 $enMsg = wfMessage( $errorMessage, $errorMessageParameters );
60 $enMsg->inLanguage( 'en' )->useDatabase( false );
61 parent::__construct( $enMsg->text() );
62 }
63
68 public function getTitleText() {
69 return $this->titleText;
70 }
71
76 public function getErrorMessage() {
77 return $this->errorMessage;
78 }
79
84 public function getErrorMessageParameters() {
85 return $this->errorMessageParameters;
86 }
87
92 public function getMessageObject() {
93 return wfMessage( $this->getErrorMessage(), $this->getErrorMessageParameters() );
94 }
95}
96
101class_alias( MalformedTitleException::class, 'MalformedTitleException' );
wfEscapeWikiText( $input)
Escapes the given text so that it may be output using addWikiText() without any linking,...
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition Message.php:157
MalformedTitleException is thrown when a TitleParser is unable to parse a title string.
__construct( $errorMessage, $titleText=null, $errorMessageParameters=[])
Interface for MediaWiki-localized exceptions.