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.

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 107

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 = '', ?string $module = NULL) {
}

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