You are here

function tmgmt_local_clear_languages_cache in Translation Management Tool 8

Same name and namespace in other branches
  1. 7 translators/tmgmt_local/tmgmt_local.module \tmgmt_local_clear_languages_cache()

Helper function for clearing the languages cache of all local translators.

Can be used in oder to clear the cache for supported target languages after the translation abilities of an local have changed.

2 calls to tmgmt_local_clear_languages_cache()
tmgmt_local_field_attach_delete in translators/tmgmt_local/tmgmt_local.module
Implements hook_field_attach_delete().
tmgmt_local_user_presave in translators/tmgmt_local/tmgmt_local.module
Implements hook_field_attach_insert().

File

translators/tmgmt_local/tmgmt_local.module, line 252
Main module file for the local translation module.

Code

function tmgmt_local_clear_languages_cache() {
  $results = \Drupal::entityQuery('tmgmt_translator')
    ->condition('plugin', 'local')
    ->execute();
  if ($results) {
    foreach (Translator::loadMultiple($results) as $translator) {
      $translator
        ->clearLanguageCache();
    }
  }
}