You are here

public function MatcherCollection::sortHelper in Linkit 8.5

Same name and namespace in other branches
  1. 8.4 src/MatcherCollection.php \Drupal\linkit\MatcherCollection::sortHelper()

Provides uasort() callback to sort plugins.

Overrides DefaultLazyPluginCollection::sortHelper

File

src/MatcherCollection.php, line 22

Class

MatcherCollection
A collection of matchers.

Namespace

Drupal\linkit

Code

public function sortHelper($aID, $bID) {
  $a_weight = $this
    ->get($aID)
    ->getWeight();
  $b_weight = $this
    ->get($bID)
    ->getWeight();
  if ($a_weight == $b_weight) {
    return strnatcasecmp($this
      ->get($aID)
      ->getLabel(), $this
      ->get($bID)
      ->getLabel());
  }
  return $a_weight < $b_weight ? -1 : 1;
}