Commit a911c113 authored by catch's avatar catch

Issue #1961542 by mtift, ParisLiakos: Added Drupal::transliteration() and...

Issue #1961542 by mtift, ParisLiakos: Added Drupal::transliteration() and replace calls to transliteration service with it.
parent 9ed73eab
......@@ -401,4 +401,14 @@ public static function csrfToken() {
return static::$container->get('csrf_token');
}
/**
* Returns the transliteration service.
*
* @return \Drupal\Core\Transliteration\PHPTransliteration
* The transliteration manager.
*/
public static function transliteration() {
return static::$container->get('transliteration');
}
}
......@@ -177,7 +177,7 @@ public function getMachineNameSuggestion() {
// @todo This is basically the same as what is done in
// \Drupal\system\MachineNameController::transliterate(), so it might make
// sense to provide a common service for the two.
$transliteration_service = \Drupal::service('transliteration');
$transliteration_service = \Drupal::transliteration();
$transliterated = $transliteration_service->transliterate($admin_label, Language::LANGCODE_DEFAULT, '_');
$replace_pattern = '[^a-z0-9_.]+';
......
......@@ -199,7 +199,7 @@ function hook_language_fallback_candidates_alter(array &$fallback_candidates) {
* // Use the current default interface language.
* $langcode = language(\Drupal\Core\Language\Language::TYPE_INTERFACE)->id;
* // Instantiate the transliteration class.
* $trans = drupal_container()->get('transliteration');
* $trans = Drupal::transliteration();
* // Use this to transliterate some text.
* $transformed = $trans->transliterate($string, $langcode);
* @endcode
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment