public function TranslationStatusForm::submitForm in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/locale/src/Form/TranslationStatusForm.php \Drupal\locale\Form\TranslationStatusForm::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
- core/
modules/ locale/ src/ Form/ TranslationStatusForm.php, line 270 - Contains \Drupal\locale\Form\TranslationStatusForm.
Class
- TranslationStatusForm
- Provides a translation status form.
Namespace
Drupal\locale\FormCode
public function submitForm(array &$form, FormStateInterface $form_state) {
$this->moduleHandler
->loadInclude('locale', 'fetch.inc');
$this->moduleHandler
->loadInclude('locale', 'bulk.inc');
$langcodes = array_filter($form_state
->getValue('langcodes'));
$projects = array_filter($form_state
->getValue('projects_update'));
// Set the translation import options. This determines if existing
// translations will be overwritten by imported strings.
$options = _locale_translation_default_update_options();
// If the status was updated recently we can immediately start fetching the
// translation updates. If the status is expired we clear it an run a batch to
// update the status and then fetch the translation updates.
$last_checked = $this->state
->get('locale.translation_last_checked');
if ($last_checked < REQUEST_TIME - LOCALE_TRANSLATION_STATUS_TTL) {
locale_translation_clear_status();
$batch = locale_translation_batch_update_build(array(), $langcodes, $options);
batch_set($batch);
}
else {
// Set a batch to download and import translations.
$batch = locale_translation_batch_fetch_build($projects, $langcodes, $options);
batch_set($batch);
// Set a batch to update configuration as well.
if ($batch = locale_config_batch_update_components($options, $langcodes)) {
batch_set($batch);
}
}
}