class RelativeOrderBase
Orders an implementation relative to other implementations.
Hierarchy
- class \Drupal\Core\Hook\Order\RelativeOrderBase implements \Drupal\Core\Hook\Order\OrderInterface
Expanded class hierarchy of RelativeOrderBase
File
-
core/
lib/ Drupal/ Core/ Hook/ Order/ RelativeOrderBase.php, line 13
Namespace
Drupal\Core\Hook\OrderView source
abstract readonly class RelativeOrderBase implements OrderInterface {
/**
* Constructor.
*
* @param list<string> $modules
* A list of modules the implementations should order against.
* @param list<array{class-string, string}> $classesAndMethods
* A list of implementations to order against, as [$class, $method].
*/
public function __construct(array $modules = [], array $classesAndMethods = []) {
if (!$this->modules && !$this->classesAndMethods) {
throw new \LogicException('Order must provide either modules or class-method pairs to order against.');
}
}
/**
* Specifies the ordering direction.
*
* @return bool
* TRUE, if the ordered implementation should be inserted after the
* implementations specified in the constructor.
*/
protected abstract function isAfter() : bool;
/**
* {@inheritdoc}
*/
public function getOperation(string $identifier) : OrderOperation {
return new BeforeOrAfter($identifier, $this->modules, array_map(static fn(array $class_and_method) => implode('::', $class_and_method), $this->classesAndMethods), $this->isAfter());
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
RelativeOrderBase::getOperation | public | function | Gets order operations specified by this object. | Overrides OrderInterface::getOperation | |
RelativeOrderBase::isAfter | abstract protected | function | Specifies the ordering direction. | 2 | |
RelativeOrderBase::__construct | public | function | Constructor. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.