MediaWiki
master
LocalizedException.php
Go to the documentation of this file.
1
<?php
21
use
MediaWiki\Message\Message
;
22
use
MediaWiki\Parser\Sanitizer
;
23
33
class
LocalizedException
extends
Exception implements
ILocalizedException
{
35
protected
$messageSpec
;
36
44
public
function
__construct
(
$messageSpec
, $code = 0, Throwable $previous =
null
) {
45
$this->messageSpec =
$messageSpec
;
46
47
// Exception->getMessage() should be in plain English, not localized.
48
// So fetch the English version of the message, without local
49
// customizations, and make a basic attempt to turn markup into text.
50
$msg = $this->
getMessageObject
()->inLanguage(
'en'
)->useDatabase(
false
)->text();
51
$msg = preg_replace(
'!</?(var|kbd|samp|code)>!'
,
'"'
, $msg );
52
$msg = Sanitizer::stripAllTags( $msg );
53
parent::__construct( $msg, $code, $previous );
54
}
55
56
public
function
getMessageObject
() {
57
return
Message::newFromSpecifier( $this->messageSpec );
58
}
59
}
LocalizedException
Basic localized exception.
Definition
LocalizedException.php:33
LocalizedException\__construct
__construct( $messageSpec, $code=0, Throwable $previous=null)
Definition
LocalizedException.php:44
LocalizedException\$messageSpec
string array MessageSpecifier $messageSpec
Definition
LocalizedException.php:35
LocalizedException\getMessageObject
getMessageObject()
Return a Message object for this exception.
Definition
LocalizedException.php:56
MediaWiki\Message\Message
The Message class deals with fetching and processing of interface message into a variety of formats.
Definition
Message.php:158
MediaWiki\Parser\Sanitizer
HTML sanitizer for MediaWiki.
Definition
Sanitizer.php:46
ILocalizedException
Interface for MediaWiki-localized exceptions.
Definition
ILocalizedException.php:31
MessageSpecifier
Definition
MessageSpecifier.php:24
includes
exception
LocalizedException.php
Generated on Sat Jul 27 2024 00:23:03 for MediaWiki by
1.10.0