MailConfigChecker/Application/Model/Exception/d3TranslatableLazyAssertionException.php

36 lines
1.0 KiB
PHP
Raw Normal View History

2023-12-11 10:38:59 +01:00
<?php
/**
2023-12-11 15:48:31 +01:00
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*
* https://www.d3data.de
2023-12-11 10:38:59 +01:00
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
2023-12-11 15:48:31 +01:00
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
* @link https://www.oxidmodule.com
2023-12-11 10:38:59 +01:00
*/
2023-12-11 15:48:31 +01:00
declare(strict_types=1);
2023-12-11 10:38:59 +01:00
namespace D3\MailConfigChecker\Application\Model\Exception;
use Assert\LazyAssertionException;
use OxidEsales\Eshop\Core\Registry;
class d3TranslatableLazyAssertionException extends LazyAssertionException
{
2023-12-12 11:28:18 +01:00
public static function fromErrors(array $errors): LazyAssertionException
2023-12-11 10:38:59 +01:00
{
2023-12-12 11:28:18 +01:00
$text = Registry::getLang()->translateString('D3_MAILCHECKER_ASSERTIONS_FAILED');
2023-12-12 11:50:41 +01:00
$message = sprintf($text, count($errors)) . "\n";
2023-12-11 10:38:59 +01:00
$i = 1;
foreach ($errors as $error) {
2023-12-12 11:50:41 +01:00
$message .= sprintf("%d) %s: %s\n", $i ++, $error->getPropertyPath(), $error->getMessage());
2023-12-11 10:38:59 +01:00
}
2023-12-12 11:43:46 +01:00
return new LazyAssertionException($message, $errors);
2023-12-11 10:38:59 +01:00
}
2023-12-12 11:50:41 +01:00
}