protected function flagViolations(EntityConstraintViolationListInterface
$violations, array
$form, FormStateInterface
$form_state) { // Flag entity level violations.
foreach ($violations->
getEntityViolations() as $violation) { /** @var \Symfony\Component\Validator\ConstraintViolationInterface $violation */
$form_state->
setErrorByName(str_replace('.', '][',
$violation->
getPropertyPath()),
$violation->
getMessage());
} // Let the form display flag violations of its fields.
$this->
getFormDisplay($form_state)->
flagWidgetsErrorsFromViolations($violations,
$form,
$form_state);
} /**
* Initializes the form state and the entity before the first form build.
*
* @param \Drupal\Core\Form\FormStateInterface $form_state
* The current state of the form.
*/
protected function init(FormStateInterface
$form_state) { // Ensure we act on the translation object corresponding to the current form
// language.