Minor extraction for code legibility
authoreileen <emcnaughton@wikimedia.org>
Tue, 9 May 2017 03:26:22 +0000 (15:26 +1200)
committereileen <emcnaughton@wikimedia.org>
Tue, 9 May 2017 03:26:22 +0000 (15:26 +1200)
CRM/Report/Form.php

index fef27a347a774d8852fe8364eae65e60d789a06b..9892c29aa1ac7d3153950b3e579214b47fb72aee 100644 (file)
@@ -690,16 +690,7 @@ class CRM_Report_Form extends CRM_Core_Form {
     }
 
     foreach ($this->_columns as $tableName => $table) {
-      // set alias
-      if (!isset($table['alias'])) {
-        $this->_columns[$tableName]['alias'] = substr($tableName, 8) .
-          '_civireport';
-      }
-      else {
-        $this->_columns[$tableName]['alias'] = $table['alias'] . '_civireport';
-      }
-
-      $this->_aliases[$tableName] = $this->_columns[$tableName]['alias'];
+      $this->setTableAlias($table, $tableName);
 
       $expFields = array();
       // higher preference to bao object
@@ -4961,4 +4952,26 @@ LEFT JOIN civicrm_contact {$field['alias']} ON {$field['alias']}.id = {$this->_a
     return $select;
   }
 
+  /**
+   * Set table alias.
+   *
+   * @param array $table
+   * @param string $tableName
+   *
+   * @return string
+   *   Alias for table.
+   */
+  protected function setTableAlias($table, $tableName) {
+    if (!isset($table['alias'])) {
+      $this->_columns[$tableName]['alias'] = substr($tableName, 8) .
+        '_civireport';
+    }
+    else {
+      $this->_columns[$tableName]['alias'] = $table['alias'] . '_civireport';
+    }
+
+    $this->_aliases[$tableName] = $this->_columns[$tableName]['alias'];
+    return $this->_aliases[$tableName];
+  }
+
 }