You are here

public function FrontendEnvironmentBase::getMachineNameSuggestion in Build Hooks 8.2

Same name and namespace in other branches
  1. 3.x src/Plugin/FrontendEnvironmentBase.php \Drupal\build_hooks\Plugin\FrontendEnvironmentBase::getMachineNameSuggestion()

File

src/Plugin/FrontendEnvironmentBase.php, line 155

Class

FrontendEnvironmentBase
Base class for Frontend environment plugins.

Namespace

Drupal\build_hooks\Plugin

Code

public function getMachineNameSuggestion() {
  $definition = $this
    ->getPluginDefinition();
  $admin_label = $definition['admin_label'];
  $transliterated = $this
    ->transliteration()
    ->transliterate($admin_label, LanguageInterface::LANGCODE_DEFAULT, '_');
  $transliterated = mb_strtolower($transliterated);
  $transliterated = preg_replace('@[^a-z0-9_.]+@', '', $transliterated);
  return $transliterated;
}