public static function SensorConfig::sort in Monitoring 8
Helper callback for uasort() to sort configuration entities by weight and label.
Overrides ConfigEntityBase::sort
File
- src/
Entity/ SensorConfig.php, line 328 - Contains \Drupal\monitoring\Entity\SensorConfig.
Class
- SensorConfig
- Represents a sensor config entity class.
Namespace
Drupal\monitoring\EntityCode
public static function sort(ConfigEntityInterface $a, ConfigEntityInterface $b) {
/**
* @var \Drupal\monitoring\Entity\SensorConfig $a
* @var \Drupal\monitoring\Entity\SensorConfig $b
*/
// Checks whether both labels and categories are equal.
if ($a
->getLabel() == $b
->getLabel() && $a
->getCategory() == $b
->getCategory()) {
return 0;
}
elseif ($a
->getCategory() != $b
->getCategory()) {
return $a
->getCategory() < $b
->getCategory() ? -1 : 1;
}
// In the end, the label's order is determined.
return $a
->getLabel() < $b
->getLabel() ? -1 : 1;
}