function FirstOrLast::apply
Changes the order of a list of hook implementations.
Parameters
list<string> $identifiers: Hook implementation identifiers, as "$class::$method", to be changed by reference. The order operation must make sure that the array remains a list, and that the values are the same as before.
array<string, string> $module_finder: Lookup map to find a module name for each implementation. This may contain more entries than $identifiers.
Overrides OrderOperation::apply
File
-
core/
lib/ Drupal/ Core/ Hook/ OrderOperation/ FirstOrLast.php, line 32
Class
- FirstOrLast
- Moves one listener to the start or end of the list.
Namespace
Drupal\Core\Hook\OrderOperationCode
public function apply(array &$identifiers, array $module_finder) : void {
$index = array_search($this->identifier, $identifiers);
if ($index === FALSE) {
// The element does not exist.
return;
}
unset($identifiers[$index]);
if ($this->isLast) {
$identifiers[] = $this->identifier;
}
else {
$identifiers = [
$this->identifier,
$identifiers,
];
}
$identifiers = array_values($identifiers);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.