本文整理汇总了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());
}