Exemplo n.º 1
0
 /**
  * Sorts active blocks by weight; sorts inactive blocks by name.
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     // Separate enabled from disabled.
     $status = (int) $b->status() - (int) $a->status();
     if ($status !== 0) {
         return $status;
     }
     // Sort by weight, unless disabled.
     if ($a->getRegion() != static::BLOCK_REGION_NONE) {
         $weight = $a->getWeight() - $b->getWeight();
         if ($weight) {
             return $weight;
         }
     }
     // Sort by label.
     return strcmp($a->label(), $b->label());
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     /** @var $a \Drupal\search\SearchPageInterface */
     /** @var $b \Drupal\search\SearchPageInterface */
     $a_status = (int) $a->status();
     $b_status = (int) $b->status();
     if ($a_status != $b_status) {
         return $a_status > $b_status ? -1 : 1;
     }
     return parent::sort($a, $b);
 }
Exemplo n.º 3
0
 /**
  * {@inheritdoc}
  */
 public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b)
 {
     $a_status = (int) $a->status();
     $b_status = (int) $b->status();
     if ($a_status != $b_status) {
         return $a_status > $b_status ? -1 : 1;
     }
     return parent::sort($a, $b);
 }