You are here

public function SiteAuditCheckContentFieldCount::getResultInfo in Site Audit 7

Same name and namespace in other branches
  1. 8.2 Check/Content/FieldCount.php \SiteAuditCheckContentFieldCount::getResultInfo()

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

Overrides SiteAuditCheckAbstract::getResultInfo

File

Check/Content/FieldCount.php, line 36
Contains \SiteAudit\Check\Content\FieldCount.

Class

SiteAuditCheckContentFieldCount
Class SiteAuditCheckContentFieldCount.

Code

public function getResultInfo() {
  if (empty($this->registry['field_api_map'])) {
    return dt('Function field_info_field_map does not exist, cannot analyze.');
  }
  $ret_val = dt('There are @count total fields.', array(
    '@count' => count($this->registry['field_api_map']),
  ));
  if (drush_get_option('detail')) {
    if (drush_get_option('html')) {
      $ret_val .= '<p>' . $ret_val . '</p>';
      $ret_val .= '<table class="table table-condensed">';
      $ret_val .= '<tr><th>' . dt('Name') . '</th><th>' . dt('Type') . '</th></tr>';
      foreach ($this->registry['field_api_map'] as $field_name => $field_data) {
        $ret_val .= "<tr><td>{$field_name}</td><td>{$field_data['type']}</td></tr>";
      }
      $ret_val .= '</table>';
    }
    else {
      $ret_val .= PHP_EOL;
      if (!drush_get_option('json')) {
        $ret_val .= str_repeat(' ', 4);
      }
      $ret_val .= dt('Name: Type') . PHP_EOL;
      if (!drush_get_option('json')) {
        $ret_val .= str_repeat(' ', 4);
      }
      $ret_val .= '----------';
      foreach ($this->registry['field_api_map'] as $field_name => $field_data) {
        $ret_val .= PHP_EOL;
        if (!drush_get_option('json')) {
          $ret_val .= str_repeat(' ', 4);
        }
        $ret_val .= $field_name . ': ' . $field_data['type'];
      }
    }
  }
  return $ret_val;
}