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