class OrderOperation
Base class for order operations.
Hierarchy
- class \Drupal\Core\Hook\OrderOperation\OrderOperation
Expanded class hierarchy of OrderOperation
5 files declare their use of OrderOperation
- HookCollectorPass.php in core/
lib/ Drupal/ Core/ Hook/ HookCollectorPass.php - ModuleHandler.php in core/
lib/ Drupal/ Core/ Extension/ ModuleHandler.php - Order.php in core/
lib/ Drupal/ Core/ Hook/ Order/ Order.php - OrderInterface.php in core/
lib/ Drupal/ Core/ Hook/ Order/ OrderInterface.php - RelativeOrderBase.php in core/
lib/ Drupal/ Core/ Hook/ Order/ RelativeOrderBase.php
File
-
core/
lib/ Drupal/ Core/ Hook/ OrderOperation/ OrderOperation.php, line 10
Namespace
Drupal\Core\Hook\OrderOperationView source
abstract class OrderOperation {
/**
* Changes the order of a list of hook implementations.
*
* @param 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.
* @param array<string, string> $module_finder
* Lookup map to find a module name for each implementation.
* This may contain more entries than $identifiers.
*/
public abstract function apply(array &$identifiers, array $module_finder) : void;
/**
* Converts the operation to a structure that can be stored in the container.
*
* @return array
* Packed operation.
*/
public final function pack() : array {
$is_before_or_after = match (get_class($this)) { BeforeOrAfter::class => TRUE,
FirstOrLast::class => FALSE,
};
return [
$is_before_or_after,
get_object_vars($this),
];
}
/**
* Converts the stored operation to objects that can apply ordering rules.
*
* @param array $packed_operation
* Packed operation.
*
* @return self
* Unpacked operation.
*/
public static final function unpack(array $packed_operation) : self {
[
$is_before_or_after,
$args,
] = $packed_operation;
$class = $is_before_or_after ? BeforeOrAfter::class : FirstOrLast::class;
return new $class(...$args);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overrides |
---|---|---|---|---|
OrderOperation::apply | abstract public | function | Changes the order of a list of hook implementations. | 2 |
OrderOperation::pack | final public | function | Converts the operation to a structure that can be stored in the container. | |
OrderOperation::unpack | final public static | function | Converts the stored operation to objects that can apply ordering rules. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.