From 8bb366760153295eb312427502d90ff1923e67c3 Mon Sep 17 00:00:00 2001 From: eileen Date: Tue, 9 May 2017 15:26:22 +1200 Subject: [PATCH] Minor extraction for code legibility --- CRM/Report/Form.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/CRM/Report/Form.php b/CRM/Report/Form.php index fef27a347a..9892c29aa1 100644 --- a/CRM/Report/Form.php +++ b/CRM/Report/Form.php @@ -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]; + } + } -- 2.25.1