private function applyErrorsToForm(FormInterface $form, Result $result)
 {
     $ex = $result->getPluginException();
     $globalErrors = $ex->getGlobalErrors();
     $dataErrors = $ex->getDataErrors();
     // add a generic error message
     if (!$dataErrors && !$globalErrors) {
         $form->addError(new FormError('form.error.invalid_payment_instruction'));
         return;
     }
     foreach ($globalErrors as $error) {
         $form->addError(new FormError($error));
     }
     foreach ($dataErrors as $path => $error) {
         $path = explode('.', $path);
         $field = $form;
         do {
             $field = $field->get(array_shift($path));
         } while ($path);
         $field->addError(new FormError($error));
     }
 }
 private function applyErrorsToForm(FormInterface $form, Result $result)
 {
     $ex = $result->getPluginException();
     $globalErrors = $ex->getGlobalErrors();
     $dataErrors = $ex->getDataErrors();
     // add a generic error message
     if (!$dataErrors && !$globalErrors) {
         $form->addError(new FormError('form.error.invalid_payment_instruction'));
         return;
     }
     foreach ($globalErrors as $error) {
         $form->addError(new FormError($error));
     }
     foreach ($dataErrors as $field => $error) {
         $form->get($field)->addError(new FormError($error));
     }
 }