Skip to content
Snippets Groups Projects
Commit a911c113 authored by catch's avatar catch
Browse files

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
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment