EntityConstraintViolationList
class EntityConstraintViolationList extends ConstraintViolationList implements EntityConstraintViolationListInterface (View source)
Implements an entity constraint violation list.
Traits
Wrapper methods for \Drupal\Core\StringTranslation\TranslationInterface.
Properties
| protected TranslationInterface | $stringTranslation | The string translation service. |
from StringTranslationTrait |
| protected FieldableEntityInterface | $entity | The entity that has been validated. |
|
| protected int[]|null | $entityViolationOffsets | Violations offsets of entity level violations. |
|
| protected array[]|null | $violationOffsetsByField | Violation offsets grouped by field. |
Methods
Translates a string to the current language or to a given language.
Formats a string containing a count of items.
Returns the number of plurals supported by a given language.
Gets the string translation service.
Groups violation offsets by field and entity level.
Gets violations flagged on entity level, not associated with any field.
Gets the violations of the given field.
Gets the violations of the given fields.
Filters this violation list by the given fields.
Filters this violation list to apply for accessible fields only.
Returns the names of all violated fields.
The entity which has been validated.
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
Details
protected TranslatableMarkup
t(string $string, array $args = [], array $options = [])
Translates a string to the current language or to a given language.
See \Drupal\Core\StringTranslation\TranslatableMarkup::__construct() for important security information and usage guidelines.
In order for strings to be localized, make them available in one of the ways supported by the
protected
formatPlural($count, $singular, $plural, array $args = [], array $options = [])
Formats a string containing a count of items.
protected
getNumberOfPlurals($langcode = NULL)
Returns the number of plurals supported by a given language.
protected TranslationInterface
getStringTranslation()
Gets the string translation service.
$this
setStringTranslation(TranslationInterface $translation)
Sets the string translation service to use.
__construct(FieldableEntityInterface $entity, array $violations = [])
{@inheritdoc}
protected
groupViolationOffsets()
Groups violation offsets by field and entity level.
Sets the $violationOffsetsByField and $entityViolationOffsets properties.
EntityConstraintViolationListInterface
getEntityViolations()
Gets violations flagged on entity level, not associated with any field.
ConstraintViolationListInterface
getByField(string $field_name)
Gets the violations of the given field.
EntityConstraintViolationListInterface
getByFields(array $field_names)
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.
$this
filterByFields(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.
$this
filterByFieldAccess(AccountInterface $account = NULL)
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.
string[]
getFieldNames()
Returns the names of all violated fields.
FieldableEntityInterface
getEntity()
The entity which has been validated.
add(ConstraintViolationInterface $violation)
{@inheritdoc}
remove($offset)
{@inheritdoc}
set($offset, ConstraintViolationInterface $violation)
{@inheritdoc}