class InvalidEntityException

Same name in other branches
  1. 10 core/lib/Drupal/Core/DefaultContent/InvalidEntityException.php \Drupal\Core\DefaultContent\InvalidEntityException

Thrown if an entity being imported has validation errors.

@internal This API is experimental.

Hierarchy

Expanded class hierarchy of InvalidEntityException

1 file declares its use of InvalidEntityException
ContentImportTest.php in core/tests/Drupal/FunctionalTests/DefaultContent/ContentImportTest.php

File

core/lib/Drupal/Core/DefaultContent/InvalidEntityException.php, line 14

Namespace

Drupal\Core\DefaultContent
View source
final class InvalidEntityException extends \RuntimeException {
    public function __construct(EntityConstraintViolationListInterface $violations, 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));
    }

}

Members

Title Sort descending Modifiers Object type Summary
InvalidEntityException::__construct public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.