You are here

public function ProcessDevelForm::submitForm in Module Builder 8.3

Form submission handler.

Overrides FormInterface::submitForm

File

module_builder_devel/src/Form/ProcessDevelForm.php, line 66

Class

ProcessDevelForm
Form for running selected analysis jobs and outputting the result.

Namespace

Drupal\module_builder_devel\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $job_list = $this
    ->getJobList($form_state);

  // Need to filter by stringity, as there is a 0 key which gets a value of
  // "0" if selected and 0 if not.
  $job_indexes_to_run = array_filter($form_state
    ->getValues()['jobs'], function ($item) {
    return is_string($item);
  });
  $jobs_to_run = array_intersect_key($job_list, $job_indexes_to_run);
  $result = [];
  foreach ($jobs_to_run as $job) {

    // Get the helper from the DCB container.
    $collector_helper = \DrupalCodeBuilder\Factory::getContainer()
      ->get($job['collector']);
    $job_data = $collector_helper
      ->collect([
      $job,
    ]);
    dpm($job_data);
  }

  // Keep the selected values in the form.
  $form_state
    ->setRebuild();
}