function ThemeManager::invoke
Invokes a hook in a particular theme.
Parameters
string $theme_key: The name of the theme (without the .theme extension).
string $hook: The name of the hook to invoke.
array $args: Arguments to pass to the hook implementation.
Return value
mixed The return value of the hook implementation.
Overrides ThemeManagerInterface::invoke
File
-
core/
lib/ Drupal/ Core/ Theme/ ThemeManager.php, line 503
Class
- ThemeManager
- Provides the default implementation of a theme manager.
Namespace
Drupal\Core\ThemeCode
public function invoke(string $theme, string $hook, array $args = []) {
$listeners = $this->getImplementationsForTheme($theme, $hook);
if ($listeners) {
if (count($listeners) > 1) {
throw new \LogicException("Theme {$theme} should not implement {$hook} more than once");
}
return reset($listeners)(...$args);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.