You are here

interface EntityConstraintViolationListInterface in Zircon Profile 8.0

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

4 files declare their use of EntityConstraintViolationListInterface
AccountForm.php in core/modules/user/src/AccountForm.php
Contains \Drupal\user\AccountForm.
CommentForm.php in core/modules/comment/src/CommentForm.php
Contains \Drupal\comment\CommentForm.
EntityFormDisplay.php in core/lib/Drupal/Core/Entity/Entity/EntityFormDisplay.php
Contains \Drupal\Core\Entity\Entity\EntityFormDisplay.
EntityFormDisplayInterface.php in core/lib/Drupal/Core/Entity/Display/EntityFormDisplayInterface.php
Contains \Drupal\Core\Entity\Display\EntityFormDisplayInterface.

File

core/lib/Drupal/Core/Entity/EntityConstraintViolationListInterface.php, line 20
Contains \Drupal\Core\Entity\EntityConstraintViolationListInterface.

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
ConstraintViolationListInterface::add public function Adds a constraint violation to this list. 1
ConstraintViolationListInterface::addAll public function Merges an existing violation list into this list. 1
ConstraintViolationListInterface::get public function Returns the violation at a given offset. 1
ConstraintViolationListInterface::has public function Returns whether the given offset exists. 1
ConstraintViolationListInterface::remove public function Removes a violation at a given offset. 1
ConstraintViolationListInterface::set public function Sets a violation at a given offset. 1
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