public BlockBase::getMachineNameSuggestion()
Suggests a machine name to identify an instance of this block.
The block plugin need not verify that the machine name is at all unique. It is only responsible for providing a baseline suggestion; calling code is responsible for ensuring whatever uniqueness is required for the use case.
Return value
string The suggested machine name.
Overrides BlockPluginInterface::getMachineNameSuggestion
File
- core/lib/Drupal/Core/Block/BlockBase.php, line 240
Class
- BlockBase
- Defines a base block implementation that most blocks plugins will extend.
Namespace
Drupal\Core\Block
Code
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. $transliterated = $this->transliteration()->transliterate($admin_label, LanguageInterface::LANGCODE_DEFAULT, '_'); $transliterated = Unicode::strtolower($transliterated); $transliterated = preg_replace('@[^a-z0-9_.]+@', '', $transliterated); return $transliterated; }
Please login to continue.