16
16
use Drupal \Core \Site \Settings ;
17
17
use Drupal \Core \Config \ConfigFactory ;
18
18
use Drupal \Core \Extension \ThemeHandler ;
19
+ use Drupal \Core \Render \RendererInterface ;
20
+ use Drupal \Core \StringTranslation \TranslatableMarkup ;
19
21
20
22
/**
21
23
* This command provides a report of the current drupal installation.
@@ -41,6 +43,20 @@ class StatusCommand extends ContainerAwareCommand
41
43
'directory ' ,
42
44
];
43
45
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
+
44
60
/**
45
61
* @var SystemManager
46
62
*/
@@ -66,27 +82,35 @@ class StatusCommand extends ContainerAwareCommand
66
82
*/
67
83
protected $ appRoot ;
68
84
85
+ /**
86
+ * @var RendererInterface
87
+ */
88
+ protected $ renderer ;
89
+
69
90
/**
70
91
* DebugCommand constructor.
71
92
*
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
76
97
* @param $appRoot
98
+ * @param RendererInterface $renderer
77
99
*/
78
100
public function __construct (
79
101
SystemManager $ systemManager = null ,
80
102
Settings $ settings ,
81
103
ConfigFactory $ configFactory ,
82
104
ThemeHandler $ themeHandler ,
83
- $ appRoot
105
+ $ appRoot ,
106
+ RendererInterface $ renderer
84
107
) {
85
108
$ this ->systemManager = $ systemManager ;
86
109
$ this ->settings = $ settings ;
87
110
$ this ->configFactory = $ configFactory ;
88
111
$ this ->themeHandler = $ themeHandler ;
89
112
$ this ->appRoot = $ appRoot ;
113
+ $ this ->renderer = $ renderer ;
90
114
parent ::__construct ();
91
115
}
92
116
@@ -149,14 +173,42 @@ protected function getSystemData()
149
173
$ systemData = [];
150
174
151
175
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) {
153
181
$ title = $ requirement ['title ' ]->render ();
154
182
} else {
155
183
$ title = $ requirement ['title ' ];
156
184
}
157
185
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 ;
160
212
}
161
213
162
214
@@ -185,8 +237,10 @@ protected function getConnectionData()
185
237
continue ;
186
238
}
187
239
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
+ }
190
244
}
191
245
192
246
$ connection_url = Database::getConnectionInfoAsUrl ();
0 commit comments