Final Class Yiisoft\Validator\Helper\MessageProcessor
| Inheritance | Yiisoft\ |
|---|
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| process() | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $translator | \ |
A translator instance used for translations of error messages. |
| $translationCategory | string |
A translation category. |
| $messageFormatter | \ |
A message formatter instance used for formats of error messages. |
| $messageFormatterLocale | string |
Locale to use when error message requires format only. |
public function __construct(
private readonly TranslatorInterface $translator,
private readonly string $translationCategory,
private readonly MessageFormatterInterface $messageFormatter,
private readonly string $messageFormatterLocale,
) {}
| public string process ( Yiisoft\ | ||
| $error | Yiisoft\ |
|
public function process(Error $error): string
{
return match ($error->getMessageProcessing()) {
Error::MESSAGE_TRANSLATE => $this->translator->translate(
$error->getMessage(),
$error->getParameters(),
$this->translationCategory,
),
Error::MESSAGE_FORMAT => $this->messageFormatter->format(
$error->getMessage(),
$error->getParameters(),
$this->messageFormatterLocale,
),
default => $error->getMessage(),
};
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.