MediaWiki master
MalformedTitleException.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Title;
8
9use Exception;
12
18class MalformedTitleException extends Exception implements ILocalizedException {
19
21 private $titleText;
23 private $errorMessage;
25 private $errorMessageParameters;
26
34 public function __construct(
35 $errorMessage, $titleText = null, $errorMessageParameters = []
36 ) {
37 $this->errorMessage = $errorMessage;
38 $this->titleText = $titleText;
39 if ( $titleText !== null ) {
40 $errorMessageParameters[] = wfEscapeWikiText( $titleText );
41 }
42 $this->errorMessageParameters = $errorMessageParameters;
43
44 // Supply something useful for Exception::getMessage() to return.
45 $enMsg = wfMessage( $errorMessage, $errorMessageParameters );
46 $enMsg->inLanguage( 'en' )->useDatabase( false );
47 parent::__construct( $enMsg->text() );
48 }
49
54 public function getTitleText() {
55 return $this->titleText;
56 }
57
62 public function getErrorMessage() {
63 return $this->errorMessage;
64 }
65
70 public function getErrorMessageParameters() {
71 return $this->errorMessageParameters;
72 }
73
78 public function getMessageObject() {
79 return wfMessage( $this->getErrorMessage(), $this->getErrorMessageParameters() );
80 }
81}
82
84class_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:144
MalformedTitleException is thrown when a TitleParser is unable to parse a title string.
__construct( $errorMessage, $titleText=null, $errorMessageParameters=[])
Interface for MediaWiki-localized exceptions.