function DevelGenerateForm::submitForm

Same name in other branches
  1. 8.x-1.x devel_generate/src/Form/DevelGenerateForm.php \Drupal\devel_generate\Form\DevelGenerateForm::submitForm()
  2. 5.x devel_generate/src/Form/DevelGenerateForm.php \Drupal\devel_generate\Form\DevelGenerateForm::submitForm()

Overrides FormInterface::submitForm

File

devel_generate/src/Form/DevelGenerateForm.php, line 101

Class

DevelGenerateForm
Defines a form that allows privileged users to generate entities.

Namespace

Drupal\devel_generate\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    try {
        $plugin_id = $this->getPluginIdFromRequest();
        $instance = $this->getPluginInstance($plugin_id);
        $instance->generate($form_state->getValues());
    } catch (\Exception $e) {
        $this->logger('DevelGenerate', $this->t('Failed to generate elements due to "%error".', [
            '%error' => $e->getMessage(),
        ]));
        $this->messenger()
            ->addMessage($this->t('Failed to generate elements due to "%error".', [
            '%error' => $e->getMessage(),
        ]));
    }
}