public function ContextManager::sortContextsByWeight in Context 8
Same name and namespace in other branches
- 8.4 src/ContextManager.php \Drupal\context\ContextManager::sortContextsByWeight()
- 8.0 src/ContextManager.php \Drupal\context\ContextManager::sortContextsByWeight()
Sorts an array of context entities by their weight.
Callback for uasort().
Parameters
ContextInterface $a: First item for comparison.
ContextInterface $b: Second item for comparison.
Return value
int The comparison result for uasort().
File
- src/
ContextManager.php, line 342
Class
- ContextManager
- This is the manager service for the context module and should not be confused with the built in contexts in Drupal.
Namespace
Drupal\contextCode
public function sortContextsByWeight(ContextInterface $a, ContextInterface $b) {
if ($a
->getWeight() == $b
->getWeight()) {
return 0;
}
return $a
->getWeight() < $b
->getWeight() ? -1 : 1;
}