You are here

public function SiteAuditCheckExtensionsDuplicate::getResultWarn in Site Audit 8.2

Same name and namespace in other branches
  1. 7 Check/Extensions/Duplicate.php \SiteAuditCheckExtensionsDuplicate::getResultWarn()

Implements \SiteAudit\Check\Abstract\getResultWarn().

Overrides SiteAuditCheckAbstract::getResultWarn

File

Check/Extensions/Duplicate.php, line 46
Contains \SiteAudit\Check\Extensions\Duplicate.

Class

SiteAuditCheckExtensionsDuplicate
Class SiteAuditCheckExtensionsDuplicate.

Code

public function getResultWarn() {
  $ret_val = dt('The following duplicate extensions were found:');
  $paths = array();
  foreach ($this->registry['extensions_dupe'] as $name => $instances) {
    foreach ($instances as $instance) {
      $paths[$name][] = $instance['path'];
    }
  }
  if (drush_get_option('html')) {
    $ret_val = '<p>' . $ret_val . '</p>';
    $ret_val .= '<table class="table table-condensed">';
    $ret_val .= '<thead><tr><th>' . dt('Name') . '</th><th>' . dt('Paths') . '</th></thead>';
    $ret_val .= '<tbody>';
    foreach ($this->registry['extensions_dupe'] as $name => $infos) {
      $ret_val .= '<tr><td>' . $name . '</td>';
      $ret_val .= '<td>' . implode('<br/>', $paths[$name]) . '</td></tr>';
    }
    $ret_val .= '</tbody>';
    $ret_val .= '</table>';
  }
  else {
    foreach ($this->registry['extensions_dupe'] as $name => $infos) {
      $ret_val .= PHP_EOL;
      if (!drush_get_option('json')) {
        $ret_val .= str_repeat(' ', 6);
      }
      $ret_val .= $name . PHP_EOL;
      $extension_list = '';
      foreach ($paths[$name] as $path) {
        $extension_list .= str_repeat(' ', 8) . $path . PHP_EOL;
      }
      $ret_val .= rtrim($extension_list);
    }
  }
  return $ret_val;
}