function LocaleImportBatch::batchSave

Same name and namespace in other branches
  1. 11.x core/modules/locale/src/LocaleImportBatch.php \Drupal\locale\LocaleImportBatch::batchSave()

Implements callback_batch_operation().

Save data of imported files.

Parameters

array|\ArrayAccess $context: Contains a list of imported files.

File

core/modules/locale/src/LocaleImportBatch.php, line 203

Class

LocaleImportBatch
Provides the locale import batch services.

Namespace

Drupal\locale

Code

public function batchSave(array|\ArrayAccess &$context) : void {
  if (isset($context['results']['files'])) {
    $request_time = $this->time
      ->getRequestTime();
    foreach ($context['results']['files'] as $file) {
      // Update the file history if both project and version are known. This
      // table is used by the automated translation update function which
      // tracks translation status of module and themes in the system. Other
      // translation files are not tracked and are therefore not stored in
      // this table.
      if ($file->project && $file->version) {
        $file->last_checked = $request_time;
        locale_translation_update_file_history($file);
      }
    }
    $context['message'] = $this->t('Translations imported.');
  }
}

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