Skip to content

Commit

Permalink
Stop passing return Properties
Browse files Browse the repository at this point in the history
  • Loading branch information
eileenmcnaughton committed Jul 11, 2019
1 parent 39c2c8d commit b6927e2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 17 deletions.
21 changes: 9 additions & 12 deletions CRM/Export/BAO/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,15 @@ public static function exportComponent($exportMode) {
* Get Query Group By Clause
* @param \CRM_Export_BAO_ExportProcessor $processor
* Export Mode
* @param array $returnProperties
* Return Properties
* @param object $query
* CRM_Contact_BAO_Query
*
* @return string
* Group By Clause
*/
public static function getGroupBy($processor, $returnProperties, $query) {
public static function getGroupBy($processor, $query) {
$groupBy = NULL;
$returnProperties = $processor->getReturnProperties();
$exportMode = $processor->getExportMode();
$queryMode = $processor->getQueryMode();
if (!empty($returnProperties['tags']) || !empty($returnProperties['groups']) ||
Expand Down Expand Up @@ -187,7 +186,6 @@ public static function exportComponents(
if ($moreReturnProperties) {
$processor->setAdditionalRequestedReturnProperties($moreReturnProperties);
}
$returnProperties = $processor->getReturnProperties();
$paymentTableId = $processor->getPaymentTableID();

if ($processor->isMergeSameAddress()) {
Expand Down Expand Up @@ -222,10 +220,10 @@ public static function exportComponents(
CRM_Contact_BAO_ProximityQuery::fixInputParams($params);
}

list($query, $select, $from, $where, $having) = $processor->runQuery($params, $order, $returnProperties);
list($query, $select, $from, $where, $having) = $processor->runQuery($params, $order);

if ($mergeSameHousehold == 1) {
$processor->setHouseholdMergeReturnProperties($returnProperties);
$processor->setHouseholdMergeReturnProperties();
}

// This perhaps only needs calling when $mergeSameHousehold == 1
Expand Down Expand Up @@ -255,7 +253,7 @@ public static function exportComponents(

$queryString = "$select $from $where $having";

$groupBy = self::getGroupBy($processor, $returnProperties, $query);
$groupBy = self::getGroupBy($processor, $query);

$queryString .= $groupBy;

Expand All @@ -269,15 +267,15 @@ public static function exportComponents(

list($field, $dir) = explode(' ', $order, 2);
$field = trim($field);
if (!empty($returnProperties[$field])) {
if (!empty($processor->getReturnProperties()[$field])) {
//CRM-15301
$queryString .= " ORDER BY $order";
}
}

$addPaymentHeader = FALSE;

list($outputColumns, $metadata) = self::getExportStructureArrays($returnProperties, $processor);
list($outputColumns, $metadata) = self::getExportStructureArrays($processor);

if (!empty($exportParams['merge_same_address']['temp_columns'])) {
// @todo - this is a temp fix - ideally later we don't set stuff only to unset it.
Expand Down Expand Up @@ -942,7 +940,6 @@ public static function componentPaymentFields() {
* However it still feels a bit like something that I'm too polite to write down and this should be seen
* as a step on the refactoring path rather than how it should be.
*
* @param array $returnProperties
* @param \CRM_Export_BAO_ExportProcessor $processor
*
* @return array
Expand All @@ -961,10 +958,10 @@ public static function componentPaymentFields() {
* - b) this code is old & outdated. Submit your answers to circular bin or better
* yet find a way to comment them for posterity.
*/
public static function getExportStructureArrays($returnProperties, $processor) {
public static function getExportStructureArrays($processor) {
$outputColumns = $metadata = [];
$queryFields = $processor->getQueryFields();
foreach ($returnProperties as $key => $value) {
foreach ($processor->getReturnProperties() as $key => $value) {
if (($key != 'location' || !is_array($value)) && !$processor->isRelationshipTypeKey($key)) {
$outputColumns[$key] = $value;
$processor->addOutputSpecification($key);
Expand Down
10 changes: 5 additions & 5 deletions CRM/Export/BAO/ExportProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -645,10 +645,11 @@ public function getHeaderForRow($field) {
/**
* @param $params
* @param $order
* @param $returnProperties
*
* @return array
*/
public function runQuery($params, $order, $returnProperties) {
public function runQuery($params, $order) {
$returnProperties = $this->getReturnProperties();
$addressWhere = '';
$params = array_merge($params, $this->getWhereParams());
if ($this->isPostalableOnly) {
Expand Down Expand Up @@ -1217,10 +1218,9 @@ public function setRelationshipReturnProperties($value, $relationshipKey) {
*
* If we are using household merge we need to add these to the relationship properties to
* be retrieved.
*
* @param $returnProperties
*/
public function setHouseholdMergeReturnProperties($returnProperties) {
public function setHouseholdMergeReturnProperties() {
$returnProperties = $this->getReturnProperties();
$returnProperties = array_diff_key($returnProperties, array_fill_keys(['location_type', 'im_provider'], 1));
foreach ($this->getHouseholdRelationshipTypes() as $householdRelationshipType) {
$this->relationshipReturnProperties[$householdRelationshipType] = $returnProperties;
Expand Down

0 comments on commit b6927e2

Please sign in to comment.