function UpdateManagerUpdate::submitForm

Same name in other branches
  1. 8.9.x core/modules/update/src/Form/UpdateManagerUpdate.php \Drupal\update\Form\UpdateManagerUpdate::submitForm()
  2. 10 core/modules/update/src/Form/UpdateManagerUpdate.php \Drupal\update\Form\UpdateManagerUpdate::submitForm()
  3. 11.x core/modules/update/src/Form/UpdateManagerUpdate.php \Drupal\update\Form\UpdateManagerUpdate::submitForm()

Overrides FormInterface::submitForm

File

core/modules/update/src/Form/UpdateManagerUpdate.php, line 373

Class

UpdateManagerUpdate
Configure update settings for this site.

Namespace

Drupal\update\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
    $this->moduleHandler
        ->loadInclude('update', 'inc', 'update.manager');
    $projects = [];
    foreach ([
        'projects',
        'disabled_projects',
    ] as $type) {
        if (!$form_state->isValueEmpty($type)) {
            $projects = array_merge($projects, array_keys(array_filter($form_state->getValue($type))));
        }
    }
    $batch_builder = (new BatchBuilder())->setFile($this->moduleHandler
        ->getModule('update')
        ->getPath() . '/update.manager.inc')
        ->setTitle($this->t('Downloading updates'))
        ->setInitMessage($this->t('Preparing to download selected updates'))
        ->setFinishCallback('update_manager_download_batch_finished');
    foreach ($projects as $project) {
        $batch_builder->addOperation('update_manager_batch_project_get', [
            $project,
            $form_state->getValue([
                'project_downloads',
                $project,
            ]),
        ]);
    }
    batch_set($batch_builder->toArray());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.