Skip to content
Permalink
Browse files

[site:status] improvements (#4063)

* Use Database::getConnectionInfoAsUrl to get the db URL

* 1

* 2

* 3

* 5

* 6

* 7

* 8

* 10

* 11

* 12

* 13

* 14

* 15

* 16

* 17

* 18

* 19

* 20

* 21

* Update StatusCommand.php

* 22
  • Loading branch information...
mondrake authored and enzolutions committed May 29, 2019
1 parent 9685080 commit df8b95b56b1816af19ec93a902b2676bebc69173
Showing with 65 additions and 11 deletions.
  1. +1 −1 config/services/site.yml
  2. +64 −10 src/Command/Site/StatusCommand.php
@@ -21,6 +21,6 @@ services:
- { name: drupal.command }
console.site_status:
class: Drupal\Console\Command\Site\StatusCommand
arguments: ['@?system.manager', '@settings', '@config.factory', '@theme_handler', '@app.root']
arguments: ['@?system.manager', '@settings', '@config.factory', '@theme_handler', '@app.root', '@renderer']
tags:
- { name: drupal.command }
@@ -16,6 +16,8 @@
use Drupal\Core\Site\Settings;
use Drupal\Core\Config\ConfigFactory;
use Drupal\Core\Extension\ThemeHandler;
use Drupal\Core\Render\RendererInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
/**
* This command provides a report of the current drupal installation.
@@ -41,6 +43,20 @@ class StatusCommand extends ContainerAwareCommand
'directory',
];
/**
* A list of system requirements to be skipped from output.
*
* @var array
*/
protected $systemDataSkipList = [
// The PHP memory limit in CLI is different from the one available to the
// web server. Skip to avoid confusion.
'php_memory_limit',
// The web server cannot be determined in CLI since Drupal takes it from
// the $_SERVER variable in HTTP requests.
'webserver',
];
/**
* @var SystemManager
*/
@@ -66,27 +82,35 @@ class StatusCommand extends ContainerAwareCommand
*/
protected $appRoot;
/**
* @var RendererInterface
*/
protected $renderer;
/**
* DebugCommand constructor.
*
* @param SystemManager $systemManager
* @param Settings $settings
* @param ConfigFactory $configFactory
* @param ThemeHandler $themeHandler
* @param SystemManager $systemManager
* @param Settings $settings
* @param ConfigFactory $configFactory
* @param ThemeHandler $themeHandler
* @param $appRoot
* @param RendererInterface $renderer
*/
public function __construct(
SystemManager $systemManager = null,
Settings $settings,
ConfigFactory $configFactory,
ThemeHandler $themeHandler,
$appRoot
$appRoot,
RendererInterface $renderer
) {
$this->systemManager = $systemManager;
$this->settings = $settings;
$this->configFactory = $configFactory;
$this->themeHandler = $themeHandler;
$this->appRoot = $appRoot;
$this->renderer = $renderer;
parent::__construct();
}
@@ -149,14 +173,42 @@ protected function getSystemData()
$systemData = [];
foreach ($requirements as $key => $requirement) {
if ($requirement['title'] instanceof \Drupal\Core\StringTranslation\TranslatableMarkup) {
if (in_array($key, $this->systemDataSkipList)) {
continue;
}
if ($requirement['title'] instanceof TranslatableMarkup) {
$title = $requirement['title']->render();
} else {
$title = $requirement['title'];
}
$value = empty($requirement['description']) ? $requirement['value'] : $requirement['value'] . ' (' . $requirement['description'] . ')';
$systemData['system'][strip_tags($title)] = strip_tags($value); ;
$value = !empty($requirement['value']) ? strip_tags($requirement['value']) : '';
if (isset($requirement['severity'])) {
switch ($requirement['severity']) {
case SystemManager::REQUIREMENT_ERROR:
$value = "<error>$value</error>";
break;
case SystemManager::REQUIREMENT_WARNING:
$value = "<comment>$value</comment>";
break;
}
}
if ($this->getIo()->isVerbose()) {
$description = !empty($requirement['description']) ? $requirement['description'] : null;
if ($description instanceof TranslatableMarkup) {
$description = $description->render();
}
if (is_array($description)) {
$description = $this->renderer->renderPlain($description);
}
$value .= $description ? ' (' . strip_tags($description) . ')' : '';
}
$systemData['system'][strip_tags($title)] = $value;
}
@@ -185,8 +237,10 @@ protected function getConnectionData()
continue;
}
$connectionKey = $this->trans('commands.site.status.messages.' . $connectionInfoKey);
$connectionData['database'][$connectionKey] = $connectionInfo['default'][$connectionInfoKey];
if (!empty($connectionInfo['default'][$connectionInfoKey])) {
$connectionKey = $this->trans('commands.site.status.messages.' . $connectionInfoKey);
$connectionData['database'][$connectionKey] = $connectionInfo['default'][$connectionInfoKey];
}
}
$connection_url = Database::getConnectionInfoAsUrl();

0 comments on commit df8b95b

Please sign in to comment.
You can’t perform that action at this time.