You are here

public static function TempStore::sortKeys in Multiversion 8

Sorts values by default language, translations in default language will be always first. This will make sure that translations in non-default languages will be saved after the translation in default language.

Parameters

string $a:

string $b:

Return value

int

File

src/Plugin/migrate/source/TempStore.php, line 81

Class

TempStore
User source from json file.

Namespace

Drupal\multiversion\Plugin\migrate\source

Code

public static function sortKeys(string $a, string $b) {
  $default_language_id = \Drupal::languageManager()
    ->getDefaultLanguage()
    ->getId();
  $a_contains_default_language_id = strpos($a, '.' . $default_language_id);
  $b_contains_default_language_id = strpos($b, '.' . $default_language_id);
  if ($a_contains_default_language_id !== FALSE && $b_contains_default_language_id === FALSE) {
    return -1;
  }
  elseif ($a_contains_default_language_id === FALSE && $b_contains_default_language_id !== FALSE) {
    return 1;
  }
  else {
    return 0;
  }
}