You are here

class PhpTransliteration in Zircon Profile 8

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

Enhances PhpTransliteration with an alter hook.

Hierarchy

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
Contains \Drupal\Tests\Core\Transliteration\PhpTransliterationTest.
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 19
Contains \Drupal\Core\Transliteration\PhpTransliteration.

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
   *   (optional) The directory where data files reside. If omitted, 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 = NULL, 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

Namesort descending Modifiers Type Description Overrides
PhpTransliteration::$dataDirectory protected property Directory where data for transliteration resides.
PhpTransliteration::$genericMap protected property Non-language-specific transliteration tables.
PhpTransliteration::$languageOverrides protected property Associative array of language-specific character transliteration tables.
PhpTransliteration::$moduleHandler protected property The module handler to execute the transliteration_overrides alter hook.
PhpTransliteration::lookupReplacement protected function Look up the generic replacement for a UTF-8 character code.
PhpTransliteration::ordUTF8 protected static function Finds the character code for a UTF-8 character: like ord() but for UTF-8.
PhpTransliteration::readGenericData protected function Reads in generic transliteration data for a bank of characters.
PhpTransliteration::readLanguageOverrides protected function Overrides \Drupal\Component\Transliteration\PhpTransliteration::readLanguageOverrides(). Overrides PhpTransliteration::readLanguageOverrides
PhpTransliteration::removeDiacritics public function Removes diacritics (accents) from certain letters. Overrides TransliterationInterface::removeDiacritics
PhpTransliteration::replace protected function Replaces a single Unicode character using the transliteration database.
PhpTransliteration::transliterate public function Transliterates text from Unicode to US-ASCII. Overrides TransliterationInterface::transliterate
PhpTransliteration::__construct public function Constructs a PhpTransliteration object. Overrides PhpTransliteration::__construct