function FilterPluginCollection::sortHelper

Provides uasort() callback to sort plugins.

Overrides DefaultLazyPluginCollection::sortHelper

File

core/modules/filter/src/FilterPluginCollection.php, line 90

Class

FilterPluginCollection
A collection of filters.

Namespace

Drupal\filter

Code

public function sortHelper($aID, $bID) {
  $a = $this->get($aID);
  $b = $this->get($bID);
  if ($a->status != $b->status) {
    return !empty($a->status) ? -1 : 1;
  }
  if ($a->weight != $b->weight) {
    return $a->weight < $b->weight ? -1 : 1;
  }
  if ($a->provider != $b->provider) {
    return strnatcasecmp($a->provider, $b->provider);
  }
  return parent::sortHelper($aID, $bID);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.