You are here

public function UpgradeStatusForm::submitForm in Upgrade Status 8

Same name and namespace in other branches
  1. 8.3 src/Form/UpgradeStatusForm.php \Drupal\upgrade_status\Form\UpgradeStatusForm::submitForm()
  2. 8.2 src/Form/UpgradeStatusForm.php \Drupal\upgrade_status\Form\UpgradeStatusForm::submitForm()

Form submission handler.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Overrides FormInterface::submitForm

File

src/Form/UpgradeStatusForm.php, line 389

Class

UpgradeStatusForm

Namespace

Drupal\upgrade_status\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $operations = [];
  $projects = $this->projectCollector
    ->collectProjects();
  $submitted = $form_state
    ->getValues();
  foreach ([
    'custom',
    'contrib',
  ] as $type) {
    if (!empty($submitted[$type])) {
      foreach ($submitted[$type]['data']['data'] as $project => $checked) {
        if ($checked !== 0) {

          // If the checkbox was checked, add a batch operation.
          $operations[] = [
            static::class . '::parseProject',
            [
              $projects[$type][$project],
            ],
          ];
        }
      }
    }
  }
  if (!empty($operations)) {
    $batch = [
      'title' => $this
        ->t('Scanning projects'),
      'operations' => $operations,
    ];
    batch_set($batch);
  }
}