You are here

public function ContextManager::sortContextsByWeight in Context 8.4

Same name and namespace in other branches
  1. 8 src/ContextManager.php \Drupal\context\ContextManager::sortContextsByWeight()
  2. 8.0 src/ContextManager.php \Drupal\context\ContextManager::sortContextsByWeight()

Sorts an array of context entities by their weight.

Callback for uasort().

Parameters

\Drupal\context\Entity\ContextInterface $a: First item for comparison.

\Drupal\context\Entity\ContextInterface $b: Second item for comparison.

Return value

int The comparison result for uasort().

File

src/ContextManager.php, line 417

Class

ContextManager
This is the manager service for the context module.

Namespace

Drupal\context

Code

public function sortContextsByWeight(ContextInterface $a, ContextInterface $b) {
  if ($a
    ->getWeight() == $b
    ->getWeight()) {
    return 0;
  }
  return $a
    ->getWeight() < $b
    ->getWeight() ? -1 : 1;
}