Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. BlockPluginTrait.php

function BlockPluginTrait::getMachineNameSuggestion

1 method overrides BlockPluginTrait::getMachineNameSuggestion()
ViewsBlock::getMachineNameSuggestion in core/modules/views/src/Plugin/Block/ViewsBlock.php

File

core/lib/Drupal/Core/Block/BlockPluginTrait.php, line 247

Class

BlockPluginTrait
Provides the base implementation of a block plugin.

Namespace

Drupal\Core\Block

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);
    // Furthermore remove any characters that are not alphanumerical from the
    // beginning and end of the transliterated string.
    $transliterated = preg_replace('@^([^a-z0-9]+)|([^a-z0-9]+)$@', '', $transliterated);
    return $transliterated;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal