function ThemeHookCollectorPass::checkInvalidHookParametersInThemes
Checks for hooks which can't be supported in theme classes.
Parameters
\Drupal\Core\Hook\Attribute\Hook $hookAttribute: The hook to check.
class-string $class: The class the hook is implemented on.
1 call to ThemeHookCollectorPass::checkInvalidHookParametersInThemes()
- ThemeHookCollectorPass::collectThemeHookImplementations in core/
lib/ Drupal/ Core/ Hook/ ThemeHookCollectorPass.php - Collects procedural and Attribute hook implementations.
File
-
core/
lib/ Drupal/ Core/ Hook/ ThemeHookCollectorPass.php, line 360
Class
- ThemeHookCollectorPass
- Collects and registers hook implementations.
Namespace
Drupal\Core\HookCode
public static function checkInvalidHookParametersInThemes(Hook $hookAttribute, string $class) : void {
// A theme cannot implement a hook on behalf of a module or other theme.
if ($hookAttribute->module !== NULL) {
throw new \LogicException("The 'module' parameter on the #[Hook] attribute is not allowed in themes. Found in {$class}.");
}
// A theme cannot alter the order of hook implementations.
if ($hookAttribute->order !== NULL) {
throw new \LogicException("The 'order' parameter on the #[Hook] attribute is not allowed in themes. Found in {$class}.");
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.