You are here

class PhpTransliteration in Drupal 10

Same name in this branch
  1. 10 core/lib/Drupal/Core/Transliteration/PhpTransliteration.php \Drupal\Core\Transliteration\PhpTransliteration
  2. 10 core/lib/Drupal/Component/Transliteration/PhpTransliteration.php \Drupal\Component\Transliteration\PhpTransliteration
Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Transliteration/PhpTransliteration.php \Drupal\Core\Transliteration\PhpTransliteration
  2. 9 core/lib/Drupal/Core/Transliteration/PhpTransliteration.php \Drupal\Core\Transliteration\PhpTransliteration

Enhances PhpTransliteration with an alter hook.

Hierarchy

  • class \Drupal\Core\Transliteration\PhpTransliteration extends \Drupal\Component\Transliteration\PhpTransliteration

Expanded class hierarchy of PhpTransliteration

See also

hook_transliteration_overrides_alter()

Related topics

1 file declares its use of PhpTransliteration
PhpTransliterationTest.php in core/tests/Drupal/Tests/Core/Transliteration/PhpTransliterationTest.php
1 string reference to 'PhpTransliteration'
core.services.yml in core/core.services.yml
core/core.services.yml
1 service uses PhpTransliteration
transliteration in core/core.services.yml
Drupal\Core\Transliteration\PhpTransliteration

File

core/lib/Drupal/Core/Transliteration/PhpTransliteration.php, line 14

Namespace

Drupal\Core\Transliteration
View source
class PhpTransliteration extends BaseTransliteration {

  /**
   * The module handler to execute the transliteration_overrides alter hook.
   *
   * @var \Drupal\Core\Extension\ModuleHandlerInterface
   */
  protected $moduleHandler;

  /**
   * Constructs a PhpTransliteration object.
   *
   * @param string $data_directory
   *   The directory where data files reside. If NULL, defaults to subdirectory
   *   'data' underneath the directory where the class's PHP file resides.
   * @param \Drupal\Core\Extension\ModuleHandlerInterface $module_handler
   *   The module handler to execute the transliteration_overrides alter hook.
   */
  public function __construct($data_directory, ModuleHandlerInterface $module_handler) {
    parent::__construct($data_directory);
    $this->moduleHandler = $module_handler;
  }

  /**
   * Overrides \Drupal\Component\Transliteration\PhpTransliteration::readLanguageOverrides().
   *
   * Allows modules to alter the language-specific $overrides array by invoking
   * hook_transliteration_overrides_alter().
   */
  protected function readLanguageOverrides($langcode) {
    parent::readLanguageOverrides($langcode);

    // Let modules alter the language-specific overrides.
    $this->moduleHandler
      ->alter('transliteration_overrides', $this->languageOverrides[$langcode], $langcode);
  }

}

Members