You are here

function configuration_ui_config_status in Configuration Management 7.2

Menu Callback: Return the status for each tracked configuration.

1 string reference to 'configuration_ui_config_status'
configuration_ui_menu in ui/configuration_ui.module
Implements hook_menu().

File

ui/configuration_ui.admin.inc, line 295
User interface functions for Configuration Management.

Code

function configuration_ui_config_status($component) {
  $components = ConfigurationManagement::getConfigurationHandler();
  if (empty($components[$component])) {
    print '';
    exit;
  }
  $tracked_in_file = ConfigurationManagement::readTrackingFile();
  $tracked = ConfigurationManagement::trackedConfigurations();
  $status = array();
  $needs_attention = 0;
  foreach ($tracked as $component_id => $info) {
    if ($component_id == $component) {
      foreach ($info as $identifier => $item) {
        $id = $component . '.' . $identifier;
        $config = ConfigurationManagement::createConfigurationInstance($id);
        $hash = $config
          ->loadFromActiveStore()
          ->getHash();
        if ($config
          ->isBroken()) {
          $status[$id] = t('Removed from Active Store');
        }
        elseif (empty($tracked_in_file['tracked'][$id])) {
          $status[$id] = t('Active Store Only');
        }
        elseif ($hash != $item['hash']) {
          $status[$id] = t('Overridden');
        }
        else {
          $status[$id] = t('In Sync');
        }
        if ($status[$id] != t('In Sync')) {
          $needs_attention++;
        }
        unset($config);
      }
      break;
    }
  }
  $return = array(
    'status' => $status,
    'diff' => module_exists('diff'),
    'needs_attention' => $needs_attention,
  );
  print drupal_json_encode($return);
  exit;
}