You are here

function lingotek_post_update_lingotek_profile_auto_request in Lingotek Translation 8.2

Update auto_request new setting with the value of auto_download for all profiles.

File

./lingotek.post_update.php, line 127
Post update functions for Lingotek.

Code

function lingotek_post_update_lingotek_profile_auto_request(&$sandbox = NULL) {
  \Drupal::classResolver(ConfigEntityUpdater::class)
    ->update($sandbox, 'lingotek_profile', function (LingotekProfileInterface $profile) {

    // Default to automatic upload, which was the previous behavior already.
    $profile
      ->setAutomaticRequest($profile
      ->hasAutomaticUpload());
    $languages = \Drupal::languageManager()
      ->getLanguages();
    foreach ($languages as $language) {
      $langcode = $language
        ->getId();
      if ($profile
        ->hasCustomSettingsForTarget($language
        ->getId())) {

        // Default to automatic upload, which was the previous behavior already,
        // and it's not dependent on the target.
        $profile
          ->setAutomaticRequestForTarget($langcode, $profile
          ->hasAutomaticUpload());
      }
    }
    return TRUE;
  });
}