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