本文整理匯總了PHP中Drupal::transliteration方法的典型用法代碼示例。如果您正苦於以下問題:PHP Drupal::transliteration方法的具體用法?PHP Drupal::transliteration怎麽用?PHP Drupal::transliteration使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Drupal
的用法示例。
在下文中一共展示了Drupal::transliteration方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getTransliteration
/**
* Get the transliteration object.
*
* @return \Drupal\Core\Transliteration\PhpTransliteration
* The transliteration object.
*/
protected function getTransliteration()
{
if (!isset($this->transliteration)) {
$this->transliteration = \Drupal::transliteration();
}
return $this->transliteration;
}
示例2: transliteration
/**
* Wraps the transliteration service.
*
* @return \Drupal\Component\Transliteration\TransliterationInterface
*/
protected function transliteration()
{
if (!$this->transliteration) {
$this->transliteration = \Drupal::transliteration();
}
return $this->transliteration;
}
示例3: getMachineNameSuggestion
/**
* {@inheritdoc}
*/
public function getMachineNameSuggestion()
{
$definition = $this->getPluginDefinition();
$admin_label = $definition['admin_label'];
// @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::transliteration();
$transliterated = $transliteration_service->transliterate($admin_label, LanguageInterface::LANGCODE_DEFAULT, '_');
$replace_pattern = '[^a-z0-9_.]+';
$transliterated = Unicode::strtolower($transliterated);
if (isset($replace_pattern)) {
$transliterated = preg_replace('@' . $replace_pattern . '@', '', $transliterated);
}
return $transliterated;
}
示例4: testTransliteration
/**
* Tests the transliteration() method.
*
* @covers ::transliteration
*/
public function testTransliteration()
{
$this->setMockContainerService('transliteration');
$this->assertNotNull(\Drupal::transliteration());
}