You are here

function tmgmt_smartling_update_8002 in TMGMT Translator Smartling 8.2

Same name and namespace in other branches
  1. 8.4 tmgmt_smartling.install \tmgmt_smartling_update_8002()
  2. 8 tmgmt_smartling.install \tmgmt_smartling_update_8002()
  3. 8.3 tmgmt_smartling.install \tmgmt_smartling_update_8002()

Add file name into job entries.

File

./tmgmt_smartling.install, line 28
Update function for the tmgmt_smartling module.

Code

function tmgmt_smartling_update_8002() {
  drupal_flush_all_caches();

  // Apply new field to a job entity.
  Drupal::service('entity.definition_update_manager')
    ->applyUpdates();
  Drupal::database()
    ->update('tmgmt_job')
    ->expression('job_file_name', 'CONCAT(:job, tmgmt_job.tjid, :underscore, tmgmt_job.source_language, :underscore, tmgmt_job.target_language, :extension)', [
    ':job' => 'JobID',
    ':underscore' => '_',
    ':extension' => '.xlf',
  ])
    ->execute();
  $translator_ids = \Drupal::configFactory()
    ->listAll('tmgmt.translator');
  foreach ($translator_ids as $id) {
    $config = \Drupal::configFactory()
      ->getEditable($id);
    if ($config && $config
      ->get('plugin') === 'smartling') {
      $config
        ->set('settings.export_format', 'xlf')
        ->save(TRUE);
    }
  }
}