function Hook::__construct

Constructs a Hook attribute object.

Parameters

string $hook: The short hook name, without the 'hook_' prefix.

string $method: (optional) The method name. If this attribute is on a method, this parameter is not required. If this attribute is on a class and this parameter is omitted, the class must have an __invoke() method, which is taken as the hook implementation.

int|null $priority: (optional) The priority of this implementation relative to other implementations of this hook. Hook implementations with higher priority are executed first. If omitted, the module order is used to order the hook implementations.

string|null $module: (optional) The module this implementation is for. This allows one module to implement a hook on behalf of another module. Defaults to the module the implementation is in.

File

core/lib/Drupal/Core/Hook/Attribute/Hook.php, line 113

Class

Hook
Attribute for defining a class method as a hook implementation.

Namespace

Drupal\Core\Hook\Attribute

Code

public function __construct(string $hook, string $method = '', ?int $priority = NULL, ?string $module = NULL) {
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.