You are here

public static function Flag::sort in Flag 8.4

Sorts the flag entities, putting disabled flags at the bottom.

Overrides ConfigEntityBase::sort

See also

\Drupal\Core\Config\Entity\ConfigEntityBase::sort()

File

src/Entity/Flag.php, line 527

Class

Flag
Provides the Flag configuration entity.

Namespace

Drupal\flag\Entity

Code

public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {

  // Check if the entities are flags, if not go with the default.
  if ($a instanceof FlagInterface && $b instanceof FlagInterface) {
    if ($a
      ->status() && $b
      ->status()) {
      return parent::sort($a, $b);
    }
    elseif (!$a
      ->status()) {
      return -1;
    }
    elseif (!$b
      ->status()) {
      return 1;
    }
  }
  return parent::sort($a, $b);
}