public function Checklist::compareChecks in Security Review 8
Helper function for sorting checks.
Parameters
\Drupal\security_review\Check $a: Check A.
\Drupal\security_review\Check $b: Check B.
Return value
int The comparison's result.
File
- src/
Checklist.php, line 242
Class
- Checklist
- Contains static functions for handling checks throughout every module.
Namespace
Drupal\security_reviewCode
public function compareChecks(Check $a, Check $b) {
// If one comes from security_review and the other doesn't, prefer the one
// with the security_review namespace.
$a_is_local = $a
->getMachineNamespace() == 'security_review';
$b_is_local = $b
->getMachineNamespace() == 'security_review';
if ($a_is_local && !$b_is_local) {
return -1;
}
elseif (!$a_is_local && $b_is_local) {
return 1;
}
else {
if ($a
->getNamespace() == $b
->getNamespace()) {
// If the namespaces match, sort by title.
return strcmp($a
->getTitle(), $b
->getTitle());
}
else {
// If the namespaces don't mach, sort by namespace.
return strcmp($a
->getNamespace(), $b
->getNamespace());
}
}
}