Pull merge.
[yaffs-website] / web / core / lib / Drupal / Core / Entity / EntityConstraintViolationListInterface.php
1 <?php
2
3 namespace Drupal\Core\Entity;
4
5 use Drupal\Core\Session\AccountInterface;
6 use Symfony\Component\Validator\ConstraintViolationListInterface;
7
8 /**
9  * Interface for the result of entity validation.
10  *
11  * The Symfony violation list is extended with methods that allow filtering
12  * violations by fields and field access. Forms leverage that to skip possibly
13  * pre-existing violations that cannot be caused or fixed by the form.
14  */
15 interface EntityConstraintViolationListInterface extends ConstraintViolationListInterface {
16
17   /**
18    * Gets violations flagged on entity level, not associated with any field.
19    *
20    * @return \Drupal\Core\Entity\EntityConstraintViolationListInterface
21    *   A list of violations on the entity level.
22    */
23   public function getEntityViolations();
24
25   /**
26    * Gets the violations of the given field.
27    *
28    * @param string $field_name
29    *   The name of the field to get violations for.
30    *
31    * @return \Symfony\Component\Validator\ConstraintViolationListInterface
32    *   The violations of the given field.
33    */
34   public function getByField($field_name);
35
36   /**
37    * Gets the violations of the given fields.
38    *
39    * When violations should be displayed for a sub-set of visible fields only,
40    * this method may be used to filter the set of visible violations first.
41    *
42    * @param string[] $field_names
43    *   The names of the fields to get violations for.
44    *
45    * @return \Drupal\Core\Entity\EntityConstraintViolationListInterface
46    *   A list of violations of the given fields.
47    */
48   public function getByFields(array $field_names);
49
50   /**
51    * Filters this violation list by the given fields.
52    *
53    * The returned object just has violations attached to the provided fields.
54    *
55    * When violations should be displayed for a sub-set of visible fields only,
56    * this method may be used to filter the set of visible violations first.
57    *
58    * @param string[] $field_names
59    *   The names of the fields to filter violations for.
60    *
61    * @return $this
62    */
63   public function filterByFields(array $field_names);
64
65   /**
66    * Filters this violation list to apply for accessible fields only.
67    *
68    * Violations for inaccessible fields are removed so the returned object just
69    * has the remaining violations.
70    *
71    * @param \Drupal\Core\Session\AccountInterface $account
72    *   (optional) The user for which to check access, or NULL to check access
73    *   for the current user. Defaults to NULL.
74    *
75    * @return $this
76    */
77   public function filterByFieldAccess(AccountInterface $account = NULL);
78
79   /**
80    * Returns the names of all violated fields.
81    *
82    * @return string[]
83    *   An array of field names.
84    */
85   public function getFieldNames();
86
87   /**
88    * The entity which has been validated.
89    *
90    * @return \Drupal\Core\Entity\FieldableEntityInterface
91    *   The entity object.
92    */
93   public function getEntity();
94
95 }