function HookOrder::before

Set a hook implementation to fire before others.

This method tries to keep existing order as much as possible. For example, if there are five hook implementations, A, B, C, D, E firing in this order then moving D before B will set it after A.

Parameters

\Drupal\Core\DependencyInjection\ContainerBuilder $container: The container builder.

string $hook: The name of the hook.

string $class_and_method: Class and method separated by :: containing the hook implementation which should be changed.

string ...$others: A list specifying the other implementations this hook should fire before. Every list member is a class and method separated by ::.

Return value

void

3 calls to HookOrder::before()
HookOrderEqualPriorityTest::testBefore in core/tests/Drupal/Tests/Core/Hook/HookOrderEqualPriorityTest.php
@covers ::before
HookOrderTest::testBefore in core/tests/Drupal/Tests/Core/Hook/HookOrderTest.php
@covers ::before
HookOrderTest::testBeforeNoChange in core/tests/Drupal/Tests/Core/Hook/HookOrderTest.php
@covers ::before

File

core/lib/Drupal/Core/Hook/HookOrder.php, line 66

Class

HookOrder
Helper methods to set priorities of hook implementations.

Namespace

Drupal\Core\Hook

Code

public static function before(ContainerBuilder $container, string $hook, string $class_and_method, string ...$others) : void {
    self::changePriority($container, $hook, $class_and_method, TRUE, array_flip($others));
}

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