You are here

public function ExtensionsDuplicate::getResultWarn in Site Audit 8.3

.

Overrides SiteAuditCheckBase::getResultWarn

File

src/Plugin/SiteAuditCheck/ExtensionsDuplicate.php, line 39

Class

ExtensionsDuplicate
Provides the ExtensionsDuplicate Check.

Namespace

Drupal\site_audit\Plugin\SiteAuditCheck

Code

public function getResultWarn() {
  $paths = [];
  foreach ($this->registry->extensions_dupe as $name => $instances) {
    foreach ($instances as $instance) {
      $paths[$name][] = $instance['path'];
    }
  }
  $headers = [
    $this
      ->t('Name'),
    $this
      ->t('Paths'),
  ];
  $rows = [];
  switch (isset($this->options['format']) ? $this->options['format'] : 'html') {
    case 'html':
      foreach ($this->registry->extensions_dupe as $name => $infos) {
        $rows[] = [
          $name,
          implode('<br/>', $paths[$name]),
        ];
      }
      break;
    case 'text':
      foreach ($this->registry->extensions_dupe as $name => $infos) {
        $rows[] = [
          $name,
          implode("\n", $paths[$name]),
        ];
      }
      break;
    case 'json':
      foreach ($this->registry->extensions_dupe as $name => $infos) {
        $rows[] = [
          'module' => $name,
          'paths' => $paths[$name],
        ];
      }
      break;
  }
  return [
    '#theme' => 'table',
    '#header' => $headers,
    '#rows' => $rows,
  ];
}