You are here

public static function Unicode::extractHook in Express 8

Extracts the hook name from a function name.

Parameters

string $string: The function name to extract the hook name from.

string $suffix: A suffix hook ending (like "alter") to also remove.

string $prefix: A prefix hook beginning (like "form") to also remove.

Return value

string The extracted hook name.

1 call to Unicode::extractHook()
Bootstrap::alter in themes/contrib/bootstrap/src/Bootstrap.php
Manages theme alter hooks as classes and allows sub-themes to sub-class.

File

themes/contrib/bootstrap/src/Utility/Unicode.php, line 32
Contains \Drupal\bootstrap\Utility\Unicode.

Class

Unicode
Extends \Drupal\Component\Utility\Unicode.

Namespace

Drupal\bootstrap\Utility

Code

public static function extractHook($string, $suffix = NULL, $prefix = NULL) {
  $regex = '^(' . implode('|', array_keys(Bootstrap::getTheme()
    ->getAncestry())) . ')';
  $regex .= $prefix ? '_' . $prefix : '';
  $regex .= $suffix ? '_|_' . $suffix . '$' : '';
  return preg_replace("/{$regex}/", '', $string);
}