public static function SensorManager::orderSensorInfo in Monitoring 7
Callback for uasort() to order sensors by category and label.
Parameters
\Drupal\monitoring\Sensor\SensorInfo $a: 1st Object to compare with.
\Drupal\monitoring\Sensor\SensorInfo $b: 2nd Object to compare with.
Return value
int Sort order of the passed in SensorInfo objects.
File
- lib/
Drupal/ monitoring/ Sensor/ SensorManager.php, line 178 - Contains \Drupal\monitoring\Sensor\SensorManager.
Class
- SensorManager
- Manages sensor definitions and settings.
Namespace
Drupal\monitoring\SensorCode
public static function orderSensorInfo(SensorInfo $a, SensorInfo $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;
}