function ComponentNegotiator::maybeNegotiateByModule
Same name in this branch
- 10 core/lib/Drupal/Core/Theme/ComponentNegotiator.php \Drupal\Core\Theme\ComponentNegotiator::maybeNegotiateByModule()
Same name in other branches
- 11.x core/modules/sdc/src/ComponentNegotiator.php \Drupal\sdc\ComponentNegotiator::maybeNegotiateByModule()
- 11.x core/lib/Drupal/Core/Theme/ComponentNegotiator.php \Drupal\Core\Theme\ComponentNegotiator::maybeNegotiateByModule()
Negotiate the component from the list of candidates for a module.
Parameters
array[] $candidates: The candidate definitions.
Return value
string|null The negotiated plugin ID, or NULL if none found.
1 call to ComponentNegotiator::maybeNegotiateByModule()
- ComponentNegotiator::doNegotiate in core/
modules/ sdc/ src/ ComponentNegotiator.php - Negotiates the active component for the current request.
File
-
core/
modules/ sdc/ src/ ComponentNegotiator.php, line 140
Class
- ComponentNegotiator
- Determines which component should be used.
Namespace
Drupal\sdcCode
private function maybeNegotiateByModule(array $candidates) : ?string {
$module_list = $this->moduleExtensionList
->getList();
if (!$module_list) {
return NULL;
}
$candidates = array_filter($candidates, static fn(array $definition) => $definition['extension_type'] === ExtensionType::Module);
$sort_by_module_weight_and_name = static function (array $definition_a, array $definition_b) use ($module_list) {
$a_weight = $module_list[$definition_a['provider']]?->weight ?? 999;
$b_weight = $module_list[$definition_b['provider']]?->weight ?? 999;
return $a_weight !== $b_weight ? $a_weight <=> $b_weight : $definition_a['provider'] <=> $definition_b['provider'];
};
uasort($candidates, $sort_by_module_weight_and_name);
$definition = reset($candidates);
return $definition ? $definition['id'] ?? NULL : NULL;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.