ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
ConstraintViolationException.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21namespace ILIAS\Refinery;
22
23use UnexpectedValueException;
24
25/***
26 * Signals the violation of some constraint on a value in a way that can be subject
27 * to i18n.
28 */
29class ConstraintViolationException extends UnexpectedValueException
30{
31 private string $languageId;
32 private array $languageValues;
33
41 public function __construct(
42 string $message,
43 string $languageId,
45 ) {
46 parent::__construct($message);
47
48 $this->languageId = $languageId;
49 $this->languageValues = $languageValues;
50 }
51
52 public function getTranslatedMessage(callable $txt): string
53 {
54 return vsprintf($txt($this->languageId), $this->languageValues);
55 }
56}
@ languageId
__construct(string $message, string $languageId,... $languageValues)
Construct a violation on a constraint.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc