Skip to content

Fix issue #1314: drush core-requirements does not output descriptions in render arrays #2582

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 10, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions commands/core/drupal/environment.inc
Original file line number Diff line number Diff line change
Expand Up @@ -389,3 +389,21 @@ function drush_get_token($value = NULL) {
function drush_url($path = NULL, array $options = array()) {
return \Drupal\Core\Url::fromUserInput('/' . $path, $options)->toString();
}

/**
* Output a Drupal render array, object or string as plain text.
*
* @param string $data
* Data to render.
*
* @return string
* The plain-text representation of the input.
*/
function drush_render($data) {
if (is_array($data)) {
$data = \Drupal::service('renderer')->renderRoot($data);
}

$data = \Drupal\Core\Mail\MailFormatHelper::htmlToText($data);
return $data;
}
10 changes: 1 addition & 9 deletions lib/Drush/Commands/core/CoreCommands.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ public function requirements($options = ['format' => 'table', 'severity' => -1,
$rows[$i] = [
'title' => (string) $info['title'],
'value' => (string) $info['value'],
'description' => (string) $info['description'],
'description' => drush_render($info['description']),
'sid' => $severity,
'severity' => @$severities[$severity]
];
Expand All @@ -136,17 +136,9 @@ public function requirements($options = ['format' => 'table', 'severity' => -1,
$i++;
}
$result = new RowsOfFields($rows);
$result->addRendererFunction([$this, 'renderCell']);
return $result;
}

public function renderCell($key, $cellData, FormatterOptions $options) {
if ($key =='value') {
$cellData = strip_tags($cellData);
}
return $cellData;
}

/**
* Return the filesystem path for modules/themes and other key folders.
*
Expand Down