blob: 412f35b09c24afa0d9f34428254f144c27cdcf1a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
<?php
namespace Drupal\Core\DefaultContent;
use Drupal\Core\Entity\EntityConstraintViolationListInterface;
use Symfony\Component\Validator\ConstraintViolationInterface;
/**
* Thrown if an entity being imported has validation errors.
*
* @internal
* This API is experimental.
*/
final class InvalidEntityException extends \RuntimeException {
public function __construct(public readonly EntityConstraintViolationListInterface $violations, public readonly string $filePath) {
$messages = [];
foreach ($violations as $violation) {
assert($violation instanceof ConstraintViolationInterface);
$messages[] = $violation->getPropertyPath() . '=' . $violation->getMessage();
}
// Example: "/path/to/file.yml: field_a=Violation 1., field_b=Violation 2.".
parent::__construct("$filePath: " . implode('||', $messages));
}
}
|