You are here

function prod_check_xmlrpc_get_data in Production check & Production monitor 8

XMLRPC callback function that returns all data of requested checks.

Parameters

ping_key: Api key for this site

checks: Array of all checks to perform

Return value

Array of all data to be displayed by the requesting site in a 'status_form' theme.

1 string reference to 'prod_check_xmlrpc_get_data'
prod_check_xmlrpc_xmlrpc in modules/prod_check_xmlrpc/prod_check_xmlrpc.module
Implements hook_xmlrpc

File

modules/prod_check_xmlrpc/prod_check_xmlrpc.module, line 56
Production check XML-RPC connector

Code

function prod_check_xmlrpc_get_data($ping_key, $checks) {
  $data = FALSE;
  $checkmanager = \Drupal::service('plugin.manager.prod_check');
  $definitions = $checkmanager
    ->getDefinitions();

  /** @var ProdCheckProcessor $xmlrpc_processor */
  $xmlrpc_processor = ProdCheckProcessor::load('xmlrpc');
  if ($xmlrpc_processor && $xmlrpc_processor
    ->getPlugin()
    ->verifyKey($ping_key)) {
    $data = [];
    foreach ($checks as $set => $calls) {
      $data[$set] = [];
      foreach ($calls as $plugin_id) {
        if (isset($definitions[$plugin_id])) {
          $plugin = $checkmanager
            ->createInstance($plugin_id, $definitions[$plugin_id]);
          $check = $xmlrpc_processor
            ->getPlugin()
            ->process($plugin);
          if (is_array($check) && !empty($check)) {
            $data[$set][$plugin_id] = $check;
          }
        }
      }
    }
  }
  return $data;
}