function HookOrderTestBase::setUpContainer
Set up three service listeners, "a", "b" and "c".
The service id, the class name and the method name are all the same.
Parameters
bool $different_priority: When TRUE, "c" will fire first, "b" second and "a" last. When FALSE, the priority will be set to be the same and the order is undefined.
Return value
void
2 calls to HookOrderTestBase::setUpContainer()
- HookOrderEqualPriorityTest::setUp in core/
tests/ Drupal/ Tests/ Core/ Hook/ HookOrderEqualPriorityTest.php - HookOrderTest::setUp in core/
tests/ Drupal/ Tests/ Core/ Hook/ HookOrderTest.php
File
-
core/
tests/ Drupal/ Tests/ Core/ Hook/ HookOrderTestBase.php, line 30
Class
Namespace
Drupal\Tests\Core\HookCode
protected function setUpContainer(bool $different_priority) : void {
$this->container = new ContainerBuilder();
foreach ([
'a',
'b',
'c',
] as $key => $name) {
$definition = $this->container
->register($name, $name)
->setAutowired(TRUE);
$definition->addTag('kernel.event_listener', [
'event' => 'drupal_hook.test',
'method' => $name,
// Do not use $key itself to avoid a 0 priority which could potentially
// lead to misleading results.
'priority' => $different_priority ? $key + 3 : 0,
]);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.