Skip to content
Snippets Groups Projects

Issue #3363197: Combined refactoring and attributes interface

Files

+ 11
4
@@ -9,7 +9,7 @@ namespace Drupal\hux\Attribute;
*/
#[\Attribute(\Attribute::TARGET_METHOD | \Attribute::IS_REPEATABLE)]
// @codingStandardsIgnoreLine
class Alter {
class Alter extends HookAttributeBase {
/**
* Constructs a new Alter.
@@ -18,10 +18,10 @@ class Alter {
* The alter name, without the 'hook_' or '_alter' components.
*/
public function __construct(
public string $alter,
private readonly string $alter,
) {
assert(!str_starts_with($alter, 'hook_'));
assert(!str_ends_with($alter, '_alter'));
assert(!str_starts_with($alter, 'hook_'), "Expected alter name without 'hook_', found $alter.");
assert(!str_ends_with($alter, '_alter'), "Expected alter name without '_alter', found $alter.");
if (in_array($alter, [
// This hook is invoked by \Drupal\Core\Extension\ModuleHandler::alter.
'module_implements_alter',
@@ -33,4 +33,11 @@ class Alter {
}
}
/**
* {@inheritdoc}
*/
public function getHookNames(): array {
return [$this->alter . '_alter'];
}
}
Loading