Exemple #1
0
  /**
   * Sorts the flag entities, putting disabled flags at the bottom.
   *
   * @see \Drupal\Core\Config\Entity\ConfigEntityBase::sort()
   */
  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->isEnabled() && $b->isEnabled()) {
        return parent::sort($a, $b);
      }
      elseif (!$a->isEnabled()) {
        return -1;
      }
      elseif (!$b->isEnabled()) {
        return 1;
      }
    }

    return parent::sort($a, $b);
  }