function Registry::getPrefixGroupedUserFunctions
Gets all user functions grouped by the word before the first underscore.
Parameters
$prefixes: An array of function prefixes by which the list can be limited.
Return value
array Functions grouped by the first prefix.
1 call to Registry::getPrefixGroupedUserFunctions()
- Registry::postProcessExtension in core/
lib/ Drupal/ Core/ Theme/ Registry.php  - Completes the theme registry adding discovered functions and hooks.
 
File
- 
              core/
lib/ Drupal/ Core/ Theme/ Registry.php, line 828  
Class
- Registry
 - Defines the theme registry service.
 
Namespace
Drupal\Core\ThemeCode
public function getPrefixGroupedUserFunctions($prefixes = []) {
  $functions = get_defined_functions();
  // If a list of prefixes is supplied, trim down the list to those items
  // only as efficiently as possible.
  if ($prefixes) {
    $theme_functions = preg_grep('/^(' . implode(')|(', $prefixes) . ')_/', $functions['user']);
  }
  else {
    $theme_functions = $functions['user'];
  }
  $grouped_functions = [];
  // Splitting user defined functions into groups by the first prefix.
  foreach ($theme_functions as $function) {
    [$first_prefix] = explode('_', $function, 2);
    $grouped_functions[$first_prefix][] = $function;
  }
  return $grouped_functions;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.