/** * Provides logging capabilities. * * @param \Drupal\security_review\Check $check * The Check the event is related to. * @param string $message * The message. * @param array $context * The context of the message. * @param int $level * Severity (RfcLogLevel). */ function hook_security_review_log(Check $check, $message, array $context, $level) { if ($check->getNamespace() == "My Module") { // Do something with the information. } }
/** * Helper function for sorting checks. * * @param \Drupal\security_review\Check $a * Check A. * @param \Drupal\security_review\Check $b * Check B. * * @return int * The comparison's result. */ public static 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. if ($a->getMachineNamespace() == 'security_review' && $b->getMachineNamespace() != 'security_review') { return -1; } elseif ($a->getMachineNamespace() != 'security_review' && $b->getMachineNamespace() == 'security_review') { 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()); } } }