Skip to content

Commit

Permalink
Fix issue drush-ops#1314: drush core-requirements does not output des…
Browse files Browse the repository at this point in the history
…criptions in render arrays
  • Loading branch information
AdamPS committed Feb 10, 2017
1 parent 65076f8 commit ccf912a
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
5 changes: 4 additions & 1 deletion commands/core/core.drush.inc
Original file line number Diff line number Diff line change
Expand Up @@ -830,6 +830,9 @@ function drush_core_requirements() {
if ($severity < $min_severity) {
unset($requirements[$key]);
}
if (isset($requirements[$key]['description'])) {
$requirements[$key]['description'] = drush_render($requirements[$key]['description']);
}
}
return $requirements;
}
Expand Down Expand Up @@ -1360,7 +1363,7 @@ function drush_core_twig_compile() {
foreach ($themes as $name => $theme) {
$searchpaths[] = $theme->getPath();
}

foreach ($searchpaths as $searchpath) {
foreach ($file = drush_scan_directory($searchpath, '/\.html.twig/', array('tests')) as $file) {
$relative = str_replace(drush_get_context('DRUSH_DRUPAL_ROOT'). '/', '', $file->filename);
Expand Down
18 changes: 18 additions & 0 deletions commands/core/drupal/environment.inc
Original file line number Diff line number Diff line change
Expand Up @@ -418,3 +418,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;
}
18 changes: 18 additions & 0 deletions commands/core/drupal/environment_7.inc
Original file line number Diff line number Diff line change
Expand Up @@ -369,3 +369,21 @@ function drush_get_token($value = NULL) {
function drush_url($path = NULL, array $options = array()) {
return url($path, $options);
}

/**
* Output a Drupal render array, object or plain 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_render($data);
}

$data = drupal_html_to_text();
return $data;
}

0 comments on commit ccf912a

Please sign in to comment.