function FilterPluginCollection::sortHelper

Same name in other branches
  1. 9 core/modules/filter/src/FilterPluginCollection.php \Drupal\filter\FilterPluginCollection::sortHelper()
  2. 8.9.x core/modules/filter/src/FilterPluginCollection.php \Drupal\filter\FilterPluginCollection::sortHelper()
  3. 11.x core/modules/filter/src/FilterPluginCollection.php \Drupal\filter\FilterPluginCollection::sortHelper()

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;
    }
    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.