Skip to content

Commit a95b7e6

Browse files
committed
Merge remote-tracking branch 'upstream/master'
2 parents ce54425 + df8b95b commit a95b7e6

File tree

2 files changed

+65
-11
lines changed

2 files changed

+65
-11
lines changed

config/services/site.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ services:
2121
- { name: drupal.command }
2222
console.site_status:
2323
class: Drupal\Console\Command\Site\StatusCommand
24-
arguments: ['@?system.manager', '@settings', '@config.factory', '@theme_handler', '@app.root']
24+
arguments: ['@?system.manager', '@settings', '@config.factory', '@theme_handler', '@app.root', '@renderer']
2525
tags:
2626
- { name: drupal.command }

src/Command/Site/StatusCommand.php

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
use Drupal\Core\Site\Settings;
1717
use Drupal\Core\Config\ConfigFactory;
1818
use Drupal\Core\Extension\ThemeHandler;
19+
use Drupal\Core\Render\RendererInterface;
20+
use Drupal\Core\StringTranslation\TranslatableMarkup;
1921

2022
/**
2123
* This command provides a report of the current drupal installation.
@@ -41,6 +43,20 @@ class StatusCommand extends ContainerAwareCommand
4143
'directory',
4244
];
4345

46+
/**
47+
* A list of system requirements to be skipped from output.
48+
*
49+
* @var array
50+
*/
51+
protected $systemDataSkipList = [
52+
// The PHP memory limit in CLI is different from the one available to the
53+
// web server. Skip to avoid confusion.
54+
'php_memory_limit',
55+
// The web server cannot be determined in CLI since Drupal takes it from
56+
// the $_SERVER variable in HTTP requests.
57+
'webserver',
58+
];
59+
4460
/**
4561
* @var SystemManager
4662
*/
@@ -66,27 +82,35 @@ class StatusCommand extends ContainerAwareCommand
6682
*/
6783
protected $appRoot;
6884

85+
/**
86+
* @var RendererInterface
87+
*/
88+
protected $renderer;
89+
6990
/**
7091
* DebugCommand constructor.
7192
*
72-
* @param SystemManager $systemManager
73-
* @param Settings $settings
74-
* @param ConfigFactory $configFactory
75-
* @param ThemeHandler $themeHandler
93+
* @param SystemManager $systemManager
94+
* @param Settings $settings
95+
* @param ConfigFactory $configFactory
96+
* @param ThemeHandler $themeHandler
7697
* @param $appRoot
98+
* @param RendererInterface $renderer
7799
*/
78100
public function __construct(
79101
SystemManager $systemManager = null,
80102
Settings $settings,
81103
ConfigFactory $configFactory,
82104
ThemeHandler $themeHandler,
83-
$appRoot
105+
$appRoot,
106+
RendererInterface $renderer
84107
) {
85108
$this->systemManager = $systemManager;
86109
$this->settings = $settings;
87110
$this->configFactory = $configFactory;
88111
$this->themeHandler = $themeHandler;
89112
$this->appRoot = $appRoot;
113+
$this->renderer = $renderer;
90114
parent::__construct();
91115
}
92116

@@ -149,14 +173,42 @@ protected function getSystemData()
149173
$systemData = [];
150174

151175
foreach ($requirements as $key => $requirement) {
152-
if ($requirement['title'] instanceof \Drupal\Core\StringTranslation\TranslatableMarkup) {
176+
if (in_array($key, $this->systemDataSkipList)) {
177+
continue;
178+
}
179+
180+
if ($requirement['title'] instanceof TranslatableMarkup) {
153181
$title = $requirement['title']->render();
154182
} else {
155183
$title = $requirement['title'];
156184
}
157185

158-
$value = empty($requirement['description']) ? $requirement['value'] : $requirement['value'] . ' (' . $requirement['description'] . ')';
159-
$systemData['system'][strip_tags($title)] = strip_tags($value); ;
186+
$value = !empty($requirement['value']) ? strip_tags($requirement['value']) : '';
187+
if (isset($requirement['severity'])) {
188+
switch ($requirement['severity']) {
189+
case SystemManager::REQUIREMENT_ERROR:
190+
$value = "<error>$value</error>";
191+
break;
192+
193+
case SystemManager::REQUIREMENT_WARNING:
194+
$value = "<comment>$value</comment>";
195+
break;
196+
197+
}
198+
}
199+
200+
if ($this->getIo()->isVerbose()) {
201+
$description = !empty($requirement['description']) ? $requirement['description'] : null;
202+
if ($description instanceof TranslatableMarkup) {
203+
$description = $description->render();
204+
}
205+
if (is_array($description)) {
206+
$description = $this->renderer->renderPlain($description);
207+
}
208+
$value .= $description ? ' (' . strip_tags($description) . ')' : '';
209+
}
210+
211+
$systemData['system'][strip_tags($title)] = $value;
160212
}
161213

162214

@@ -185,8 +237,10 @@ protected function getConnectionData()
185237
continue;
186238
}
187239

188-
$connectionKey = $this->trans('commands.site.status.messages.' . $connectionInfoKey);
189-
$connectionData['database'][$connectionKey] = $connectionInfo['default'][$connectionInfoKey];
240+
if (!empty($connectionInfo['default'][$connectionInfoKey])) {
241+
$connectionKey = $this->trans('commands.site.status.messages.' . $connectionInfoKey);
242+
$connectionData['database'][$connectionKey] = $connectionInfo['default'][$connectionInfoKey];
243+
}
190244
}
191245

192246
$connection_url = Database::getConnectionInfoAsUrl();

0 commit comments

Comments
 (0)