Esempio n. 1
0
 /**
  * Parse Drupal core status.
  *
  * @return DrupalCoreStatus
  *   The parsed Drupal core status information fetched via 'drush core-status').
  *
  * @throws \Exception
  */
 protected static function parseStatus()
 {
     // Load from cache (if exists).
     if ($status = static::parseStatusCache()) {
         return $status;
     }
     // Custom output capture to ensure no output at all.
     ob_start();
     // Load Drupal core status via Drush.
     $output = Drush::exec()->arg('core-status')->option('format=json')->run()->getMessage();
     // End custom output capture.
     ob_end_clean();
     // Unable to parse Drupal core status JSON.
     if (!($status = @json_decode($output))) {
         print $output;
         throw new \Exception(__CLASS__ . ' - Unable to parse Drupal status.');
     }
     // Cast status.
     $status = new DrupalCoreStatus((object) $status);
     // Save to cache (if bootstrapped).
     if (static::statusIsBootstrapped($status)) {
         static::parseStatusCache($status);
     }
     return $status;
 }