Merge pull request #15243 from Tithugues/feature/message-in-message-is-self
Message in Message class is self
This commit is contained in:
commit
0ccae90725
@ -144,9 +144,9 @@ class Message
|
||||
array $params = [],
|
||||
int $sanitize = Message::SANITIZE_NONE
|
||||
) {
|
||||
$this->setString($string, $sanitize & Message::SANITIZE_STRING);
|
||||
$this->setString($string, $sanitize & self::SANITIZE_STRING);
|
||||
$this->setNumber($number);
|
||||
$this->setParams($params, $sanitize & Message::SANITIZE_PARAMS);
|
||||
$this->setParams($params, $sanitize & self::SANITIZE_PARAMS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -177,7 +177,7 @@ class Message
|
||||
$string = __('Your SQL query has been executed successfully.');
|
||||
}
|
||||
|
||||
return new Message($string, Message::SUCCESS);
|
||||
return new Message($string, self::SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -196,7 +196,7 @@ class Message
|
||||
$string = __('Error');
|
||||
}
|
||||
|
||||
return new Message($string, Message::ERROR);
|
||||
return new Message($string, self::ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,7 +214,7 @@ class Message
|
||||
*/
|
||||
public static function notice(string $string): self
|
||||
{
|
||||
return new Message($string, Message::NOTICE);
|
||||
return new Message($string, self::NOTICE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -248,7 +248,7 @@ class Message
|
||||
*/
|
||||
public static function getMessageForAffectedRows(int $rows): self
|
||||
{
|
||||
$message = Message::success(
|
||||
$message = self::success(
|
||||
_ngettext('%1$d row affected.', '%1$d rows affected.', $rows)
|
||||
);
|
||||
$message->addParam($rows);
|
||||
@ -267,7 +267,7 @@ class Message
|
||||
*/
|
||||
public static function getMessageForDeletedRows(int $rows): self
|
||||
{
|
||||
$message = Message::success(
|
||||
$message = self::success(
|
||||
_ngettext('%1$d row deleted.', '%1$d rows deleted.', $rows)
|
||||
);
|
||||
$message->addParam($rows);
|
||||
@ -286,7 +286,7 @@ class Message
|
||||
*/
|
||||
public static function getMessageForInsertedRows(int $rows): self
|
||||
{
|
||||
$message = Message::success(
|
||||
$message = self::success(
|
||||
_ngettext('%1$d row inserted.', '%1$d rows inserted.', $rows)
|
||||
);
|
||||
$message->addParam($rows);
|
||||
@ -305,7 +305,7 @@ class Message
|
||||
*/
|
||||
public static function rawError(string $message): self
|
||||
{
|
||||
return Message::raw($message, Message::ERROR);
|
||||
return self::raw($message, self::ERROR);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -320,7 +320,7 @@ class Message
|
||||
*/
|
||||
public static function rawNotice(string $message): self
|
||||
{
|
||||
return Message::raw($message, Message::NOTICE);
|
||||
return self::raw($message, self::NOTICE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -335,7 +335,7 @@ class Message
|
||||
*/
|
||||
public static function rawSuccess(string $message): self
|
||||
{
|
||||
return Message::raw($message, Message::SUCCESS);
|
||||
return self::raw($message, self::SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -349,10 +349,10 @@ class Message
|
||||
public function isSuccess(bool $set = false): bool
|
||||
{
|
||||
if ($set) {
|
||||
$this->setNumber(Message::SUCCESS);
|
||||
$this->setNumber(self::SUCCESS);
|
||||
}
|
||||
|
||||
return $this->getNumber() === Message::SUCCESS;
|
||||
return $this->getNumber() === self::SUCCESS;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -366,10 +366,10 @@ class Message
|
||||
public function isNotice(bool $set = false): bool
|
||||
{
|
||||
if ($set) {
|
||||
$this->setNumber(Message::NOTICE);
|
||||
$this->setNumber(self::NOTICE);
|
||||
}
|
||||
|
||||
return $this->getNumber() === Message::NOTICE;
|
||||
return $this->getNumber() === self::NOTICE;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -383,10 +383,10 @@ class Message
|
||||
public function isError(bool $set = false): bool
|
||||
{
|
||||
if ($set) {
|
||||
$this->setNumber(Message::ERROR);
|
||||
$this->setNumber(self::ERROR);
|
||||
}
|
||||
|
||||
return $this->getNumber() === Message::ERROR;
|
||||
return $this->getNumber() === self::ERROR;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -412,7 +412,7 @@ class Message
|
||||
public function setMessage(string $message, bool $sanitize = false): void
|
||||
{
|
||||
if ($sanitize) {
|
||||
$message = Message::sanitize($message);
|
||||
$message = self::sanitize($message);
|
||||
}
|
||||
$this->message = $message;
|
||||
}
|
||||
@ -428,7 +428,7 @@ class Message
|
||||
public function setString(string $string, $sanitize = true): void
|
||||
{
|
||||
if ($sanitize) {
|
||||
$string = Message::sanitize($string);
|
||||
$string = self::sanitize($string);
|
||||
}
|
||||
$this->string = $string;
|
||||
}
|
||||
@ -459,7 +459,7 @@ class Message
|
||||
*/
|
||||
public function addParam($param): void
|
||||
{
|
||||
if ($param instanceof Message || is_float($param) || is_int($param)) {
|
||||
if ($param instanceof self || is_float($param) || is_int($param)) {
|
||||
$this->params[] = $param;
|
||||
} else {
|
||||
$this->params[] = htmlspecialchars((string) $param);
|
||||
@ -480,7 +480,7 @@ class Message
|
||||
*/
|
||||
public function addParamHtml(string $param): void
|
||||
{
|
||||
$this->params[] = Message::notice($param);
|
||||
$this->params[] = self::notice($param);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -516,8 +516,8 @@ class Message
|
||||
/**
|
||||
* Real implementation of adding message
|
||||
*
|
||||
* @param Message $message to be added
|
||||
* @param string $separator to use between this and previous string/message
|
||||
* @param self $message to be added
|
||||
* @param string $separator to use between this and previous string/message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -532,8 +532,8 @@ class Message
|
||||
/**
|
||||
* add another raw message to be concatenated on displaying
|
||||
*
|
||||
* @param Message $message to be added
|
||||
* @param string $separator to use between this and previous string/message
|
||||
* @param self $message to be added
|
||||
* @param string $separator to use between this and previous string/message
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
@ -552,7 +552,7 @@ class Message
|
||||
*/
|
||||
public function addText(string $message, string $separator = ' '): void
|
||||
{
|
||||
$this->addMessageToList(Message::notice(htmlspecialchars($message)), $separator);
|
||||
$this->addMessageToList(self::notice(htmlspecialchars($message)), $separator);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -565,7 +565,7 @@ class Message
|
||||
*/
|
||||
public function addHtml(string $message, string $separator = ' '): void
|
||||
{
|
||||
$this->addMessageToList(Message::rawNotice($message), $separator);
|
||||
$this->addMessageToList(self::rawNotice($message), $separator);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -579,7 +579,7 @@ class Message
|
||||
public function setParams($params, $sanitize = false): void
|
||||
{
|
||||
if ($sanitize) {
|
||||
$params = Message::sanitize($params);
|
||||
$params = self::sanitize($params);
|
||||
}
|
||||
$this->params = $params;
|
||||
}
|
||||
@ -617,7 +617,7 @@ class Message
|
||||
{
|
||||
if (is_array($message)) {
|
||||
foreach ($message as $key => $val) {
|
||||
$message[$key] = Message::sanitize($val);
|
||||
$message[$key] = self::sanitize($val);
|
||||
}
|
||||
|
||||
return $message;
|
||||
@ -697,11 +697,11 @@ class Message
|
||||
$message = $this->getMessageWithIcon($message);
|
||||
}
|
||||
if (count($this->getParams()) > 0) {
|
||||
$message = Message::format($message, $this->getParams());
|
||||
$message = self::format($message, $this->getParams());
|
||||
}
|
||||
|
||||
if ($this->useBBCode) {
|
||||
$message = Message::decodeBB($message);
|
||||
$message = self::decodeBB($message);
|
||||
}
|
||||
|
||||
foreach ($this->getAddedMessages() as $add_message) {
|
||||
@ -749,7 +749,7 @@ class Message
|
||||
*/
|
||||
public function getLevel(): string
|
||||
{
|
||||
return Message::$level[$this->getNumber()];
|
||||
return self::$level[$this->getNumber()];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -807,7 +807,7 @@ class Message
|
||||
} else {
|
||||
$image = 's_notice';
|
||||
}
|
||||
$message = Message::notice(Util::getImage($image)) . " " . $message;
|
||||
$message = self::notice(Util::getImage($image)) . " " . $message;
|
||||
return $message;
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user