Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x

InvalidEntityException.php

Namespace

Drupal\Core\DefaultContent

File

core/lib/Drupal/Core/DefaultContent/InvalidEntityException.php

View source
<?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(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));
    }

}

Classes

Title Deprecated Summary
InvalidEntityException Thrown if an entity being imported has validation errors.

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal