You are here

private function SpiController::getSystemStatus in Acquia Connector 8

Same name and namespace in other branches
  1. 8.2 src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getSystemStatus()
  2. 3.x src/Controller/SpiController.php \Drupal\acquia_connector\Controller\SpiController::getSystemStatus()

This function is a trimmed version of Drupal's system_status function.

Return value

array System status array.

1 call to SpiController::getSystemStatus()
SpiController::get in src/Controller/SpiController.php
Gather site profile information about this site.

File

src/Controller/SpiController.php, line 567

Class

SpiController
SPI Controller class.

Namespace

Drupal\acquia_connector\Controller

Code

private function getSystemStatus() {
  $data = [];
  if (\Drupal::hasContainer()) {
    $profile = \Drupal::installProfile();
  }
  else {
    $profile = BootstrapConfigStorageFactory::getDatabaseStorage()
      ->read('core.extension')['profile'];
  }
  if ($profile != 'standard') {
    $extension_list = \Drupal::service('extension.list.module');
    $info = $extension_list
      ->getExtensionInfo($profile);
    $data['install_profile'] = [
      'title' => 'Install profile',
      'value' => sprintf('%s (%s-%s)', $info['name'], $profile, $info['version']),
    ];
  }
  $data['php'] = [
    'title' => 'PHP',
    'value' => phpversion(),
  ];
  $conf_dir = TRUE;
  $settings = TRUE;
  $dir = DrupalKernel::findSitePath(\Drupal::request(), TRUE);
  if (is_writable($dir) || is_writable($dir . '/settings.php')) {
    $value = 'Not protected';
    if (is_writable($dir)) {
      $conf_dir = FALSE;
    }
    elseif (is_writable($dir . '/settings.php')) {
      $settings = FALSE;
    }
  }
  else {
    $value = 'Protected';
  }
  $data['settings.php'] = [
    'title' => 'Configuration file',
    'value' => $value,
    'conf_dir' => $conf_dir,
    'settings' => $settings,
  ];
  $cron_last = \Drupal::state()
    ->get('system.cron_last');
  if (!is_numeric($cron_last)) {
    $cron_last = \Drupal::state()
      ->get('install_time', 0);
  }
  $data['cron'] = [
    'title' => 'Cron maintenance tasks',
    'value' => sprintf('Last run %s ago', \Drupal::service('date.formatter')
      ->formatInterval(\Drupal::time()
      ->getRequestTime() - $cron_last)),
    'cron_last' => $cron_last,
  ];
  if (!empty(Settings::get('update_free_access'))) {
    $data['update access'] = [
      'value' => 'Not protected',
      'protected' => FALSE,
    ];
  }
  else {
    $data['update access'] = [
      'value' => 'Protected',
      'protected' => TRUE,
    ];
  }
  $data['update access']['title'] = 'Access to update.php';
  if (!$this
    ->moduleHandler()
    ->moduleExists('update')) {
    $data['update status'] = [
      'value' => 'Not enabled',
    ];
  }
  else {
    $data['update status'] = [
      'value' => 'Enabled',
    ];
  }
  $data['update status']['title'] = 'Update notifications';
  return $data;
}