You are here

interface EntityConstraintViolationListInterface in Drupal 9

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Entity/EntityConstraintViolationListInterface.php \Drupal\Core\Entity\EntityConstraintViolationListInterface

Interface for the result of entity validation.

The Symfony violation list is extended with methods that allow filtering violations by fields and field access. Forms leverage that to skip possibly pre-existing violations that cannot be caused or fixed by the form.

Hierarchy

Expanded class hierarchy of EntityConstraintViolationListInterface

All classes that implement EntityConstraintViolationListInterface

10 files declare their use of EntityConstraintViolationListInterface
AccountForm.php in core/modules/user/src/AccountForm.php
CommentForm.php in core/modules/comment/src/CommentForm.php
ContentTranslationFieldSyncRevisionTest.php in core/modules/content_translation/tests/src/Kernel/ContentTranslationFieldSyncRevisionTest.php
EntityFormDisplay.php in core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
EntityFormDisplayInterface.php in core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php

... See full list

File

core/lib/Drupal/Core/Entity/EntityConstraintViolationListInterface.php, line 15

Namespace

Drupal\Core\Entity
View source
interface EntityConstraintViolationListInterface extends ConstraintViolationListInterface {

  /**
   * Gets violations flagged on entity level, not associated with any field.
   *
   * @return \Drupal\Core\Entity\EntityConstraintViolationListInterface
   *   A list of violations on the entity level.
   */
  public function getEntityViolations();

  /**
   * Gets the violations of the given field.
   *
   * @param string $field_name
   *   The name of the field to get violations for.
   *
   * @return \Symfony\Component\Validator\ConstraintViolationListInterface
   *   The violations of the given field.
   */
  public function getByField($field_name);

  /**
   * Gets the violations of the given fields.
   *
   * When violations should be displayed for a sub-set of visible fields only,
   * this method may be used to filter the set of visible violations first.
   *
   * @param string[] $field_names
   *   The names of the fields to get violations for.
   *
   * @return \Drupal\Core\Entity\EntityConstraintViolationListInterface
   *   A list of violations of the given fields.
   */
  public function getByFields(array $field_names);

  /**
   * Filters this violation list by the given fields.
   *
   * The returned object just has violations attached to the provided fields.
   *
   * When violations should be displayed for a sub-set of visible fields only,
   * this method may be used to filter the set of visible violations first.
   *
   * @param string[] $field_names
   *   The names of the fields to filter violations for.
   *
   * @return $this
   */
  public function filterByFields(array $field_names);

  /**
   * Filters this violation list to apply for accessible fields only.
   *
   * Violations for inaccessible fields are removed so the returned object just
   * has the remaining violations.
   *
   * @param \Drupal\Core\Session\AccountInterface $account
   *   (optional) The user for which to check access, or NULL to check access
   *   for the current user. Defaults to NULL.
   *
   * @return $this
   */
  public function filterByFieldAccess(AccountInterface $account = NULL);

  /**
   * Returns the names of all violated fields.
   *
   * @return string[]
   *   An array of field names.
   */
  public function getFieldNames();

  /**
   * The entity which has been validated.
   *
   * @return \Drupal\Core\Entity\FieldableEntityInterface
   *   The entity object.
   */
  public function getEntity();

}

Members

Namesort descending Modifiers Type Description Overrides
EntityConstraintViolationListInterface::filterByFieldAccess public function Filters this violation list to apply for accessible fields only. 1
EntityConstraintViolationListInterface::filterByFields public function Filters this violation list by the given fields. 1
EntityConstraintViolationListInterface::getByField public function Gets the violations of the given field. 1
EntityConstraintViolationListInterface::getByFields public function Gets the violations of the given fields. 1
EntityConstraintViolationListInterface::getEntity public function The entity which has been validated. 1
EntityConstraintViolationListInterface::getEntityViolations public function Gets violations flagged on entity level, not associated with any field. 1
EntityConstraintViolationListInterface::getFieldNames public function Returns the names of all violated fields. 1