Documentation

CRM_Export_BAO_ExportProcessor
in package

Class CRM_Export_BAO_ExportProcessor

Class to handle logic of export.

Table of Contents

Properties

$additionalFieldsForPostalExport  : array<string|int, mixed>
Additional fields required to export postal fields.
$additionalFieldsForSameAddressMerge  : array<string|int, mixed>
Fields that need to be retrieved for address merge purposes but should not be in output.
$additionalRequestedReturnProperties  : array<string|int, mixed>
Additional fields to return.
$addresseeGreetingTemplate  : mixed
$componentClause  : string
Clause from component search.
$componentTable  : string
$contactGreetingFields  : array<string|int, mixed>
Fields used for merging same contacts.
$contactsToMerge  : array<string|int, mixed>
Contacts to be merged by virtue of their shared address.
$exportedHouseholds  : array<string|int, mixed>
IDs of households that have already been exported.
$exportMode  : int
$greetingOptions  : array<string|int, mixed>
Greeting options mapping to various greeting ids.
$householdsToSkip  : array<string|int, mixed>
Households to skip during export as they will be exported via their relationships anyway.
$ids  : array<string|int, mixed>
An array of primary IDs of the entity being exported.
$isMergeSameAddress  : bool
Should contacts with the same address be merged.
$isMergeSameHousehold  : bool
Is the contact being merged into a single household.
$isPostalableOnly  : bool
Only export contacts that can receive postal mail.
$outputSpecification  : array<string|int, mixed>
$postalGreetingTemplate  : mixed
$queryFields  : array<string|int, mixed>
Array of fields in the main query.
$queryMode  : int
$queryOperator  : string
Either AND or OR.
$relatedContactValues  : array<string|int, mixed>
Export values for related contacts.
$relationshipReturnProperties  : array<string|int, mixed>
Array of properties to retrieve for relationships.
$relationshipTypes  : array<string|int, mixed>
Key representing the head of household in the relationship array.
$requestedFields  : array<string|int, mixed>|null
Requested output fields.
$returnProperties  : array<string|int, mixed>
$temporaryTable  : string
Name of a temporary table created to hold the results.

Methods

__construct()  : mixed
CRM_Export_BAO_ExportProcessor constructor.
addOutputSpecification()  : mixed
Add a row to the specification for how to output data.
buildMasterCopyArray()  : mixed
Build array for merging same addresses.
buildRow()  : array<string|int, mixed>|bool
Build the row for output.
createTempTable()  : mixed
Create the temporary table for output.
defaultReturnProperty()  : string
Get default return property for export based on mode
determineReturnProperties()  : array<string|int, mixed>
Determine the required return properties from the input parameters.
fetchRelationshipDetails()  : mixed
Get the values of linked household contact.
getAdditionalFieldsForPostalExport()  : array<string|int, mixed>
Get additional fields required to do a postal export.
getAdditionalFieldsForSameAddressMerge()  : array<string|int, mixed>
Get additional non-visible fields for address merge purposes.
getAdditionalRequestedReturnProperties()  : array<string|int, mixed>
Get additional return properties.
getAdditionalReturnProperties()  : array<string|int, mixed>
Get array of fields to return, over & above those defined in the main contact exportable fields.
getAddresseeGreetingTemplate()  : mixed
getComponentClause()  : string
getComponentPaymentFields()  : array<string|int, mixed>
Get fields that indicate payment fields have been requested for a component.
getComponentTable()  : string
getDefaultReturnProperties()  : array<string|int, mixed>
Get the default properties when not specified.
getExportFileName()  : string
Get the name for the export file.
getExportMode()  : int
getExportStructureArrays()  : array<string|int, mixed>
Get the various arrays that we use to structure our output.
getGroupBy()  : string
getHeaderForRow()  : string
Get the label for the header row based on the field to output.
getHeaderRows()  : array<string|int, mixed>
getHouseholdMergeTypeForRow()  : bool
If this row has a household whose details we should use get the relationship type key.
getHouseholdRelationshipTypes()  : mixed
Return relationship types for household merge.
getIds()  : array<string|int, mixed>
getMetadata()  : array<string|int, mixed>
getMetaDataForField()  : array<string|int, mixed>
Get the metadata for the given field.
getMungedFieldName()  : string
Get the munged field name.
getPaymentHeaders()  : mixed
Get headers for payment fields.
getPaymentTableID()  : mixed
Get the name of the id field in the table that connects contributions to the export entity.
getPostalGreetingTemplate()  : mixed
getPreview()  : array<string|int, mixed>
Preview export output.
getQueryFields()  : array<string|int, mixed>
getQueryMode()  : int
getQueryOperator()  : string
getRelatedHouseholdID()  : int
Get the id of the related household.
getRelationshipReturnProperties()  : array<string|int, mixed>
Get return properties by relationship.
getRelationshipTypes()  : array<string|int, mixed>
getRelationshipValue()  : string
Get the value for a relationship type field.
getRequestedFields()  : array<string|int, mixed>|null
getReturnProperties()  : array<string|int, mixed>
getSqlColumnDefinition()  : mixed
Get the sql column definition for the given field.
getSQLColumns()  : array<string|int, mixed>
getTemporaryTable()  : string
getTransformedFieldValue()  : string
getValidLocationFields()  : array<string|int, mixed>
Get the default location fields to request.
getWhereParams()  : mixed
Get params for the where criteria.
isExportPaymentFields()  : mixed
Should payment fields be appended to the export.
isExportSpecifiedPaymentFields()  : bool
Has specific payment fields been requested (as opposed to via all fields).
isHouseholdExported()  : bool
Has the household already been exported.
isHouseholdMergeRelationshipTypeKey()  : bool
isMergeSameAddress()  : bool
Should contacts with the same address be merged.
isMergeSameHousehold()  : bool
isPostalableOnly()  : bool
isRelationshipTypeKey()  : bool
markHouseholdExported()  : mixed
Mark the given household as already exported.
mergeSameAddress()  : mixed
Merge contacts with the same address.
replaceMergeTokens()  : array<string|int, mixed>
Replace contact greetings in merged contacts.
runQuery()  : array<string|int, mixed>
setAdditionalFieldsForPostalExport()  : mixed
Set additional fields required for a postal export.
setAdditionalFieldsForSameAddressMerge()  : mixed
Set additional non-visible fields for address merge purposes.
setAdditionalRequestedReturnProperties()  : mixed
Set additional return properties.
setAddresseeGreetingTemplate()  : mixed
setColumnAsCalculationOnly()  : mixed
Mark a column as only required for calculations.
setComponentClause()  : mixed
setComponentTable()  : mixed
Set the component table (if any).
setExportMode()  : mixed
setGreetingOptions()  : mixed
Set the greeting options, if relevant.
setHouseholdMergeReturnProperties()  : mixed
Add the main return properties to the household merge properties if needed for merging.
setIds()  : mixed
setIsMergeSameAddress()  : mixed
Set same address is to be merged.
setIsMergeSameHousehold()  : mixed
setIsPostalableOnly()  : mixed
setPostalGreetingTemplate()  : mixed
setQueryFields()  : mixed
setQueryMode()  : mixed
Set the query mode based on the export mode.
setQueryOperator()  : mixed
setRelationshipReturnProperties()  : array<string|int, mixed>
Add the field to relationship return properties & return it.
setRelationshipTypes()  : mixed
setRelationshipValue()  : mixed
Set the value for a relationship type field.
setRequestedFields()  : mixed
setReturnProperties()  : mixed
setSqlColumnDefn()  : mixed
setTemporaryTable()  : mixed
trimNonTokensFromAddressString()  : mixed
The function unsets static part of the string, if token is the dynamic part.
writeCSVFromTable()  : mixed
Write to the csv from the temp table.
buildRelationshipFieldsForRow()  : mixed
cacheContactGreetings()  : mixed
Cache the greeting fields for the given contact.
getContactGreeting()  : string
Get the greeting value for the given contact.
getContactPortionOfGreeting()  : mixed|string
Get the portion of the greeting string that relates to the contact.
getOutputSpecificationFieldKey()  : string
Get the mysql field name key.
getOutputSpecificationIndex()  : string
In order to respect the history of this class we need to index kinda illogically.
getOutputSpecificationLabel()  : string
Get the compiled label for the column.
hasRequestedComponentPaymentFields()  : bool
Have component payment fields been requested.
instantiateTempTable()  : mixed
Set up the temp table.
isHouseholdToSkip()  : bool
Is this contact a household that is already set to be exported by virtue of it's household members.
setGreetingStringsForSameAddressMerge()  : mixed
Set the template strings to be used when merging two contacts with the same address.
writeRows()  : mixed
Write rows to the csv.

Properties

$additionalFieldsForPostalExport

Additional fields required to export postal fields.

protected array<string|int, mixed> $additionalFieldsForPostalExport = []

$additionalFieldsForSameAddressMerge

Fields that need to be retrieved for address merge purposes but should not be in output.

protected array<string|int, mixed> $additionalFieldsForSameAddressMerge = []

$additionalRequestedReturnProperties

Additional fields to return.

protected array<string|int, mixed> $additionalRequestedReturnProperties = []

This doesn't make much sense when we have a fields set but search build add it's own onto the 'Primary fields' (all) option.

$addresseeGreetingTemplate

protected mixed $addresseeGreetingTemplate

$componentClause

Clause from component search.

protected string $componentClause = ''

$contactGreetingFields

Fields used for merging same contacts.

protected array<string|int, mixed> $contactGreetingFields = []

$contactsToMerge

Contacts to be merged by virtue of their shared address.

protected array<string|int, mixed> $contactsToMerge = []

$exportedHouseholds

IDs of households that have already been exported.

protected array<string|int, mixed> $exportedHouseholds = []

$greetingOptions

Greeting options mapping to various greeting ids.

protected array<string|int, mixed> $greetingOptions = []

This stores the option values for the addressee, postal_greeting & email_greeting option groups.

$householdsToSkip

Households to skip during export as they will be exported via their relationships anyway.

protected array<string|int, mixed> $householdsToSkip = []

$ids

An array of primary IDs of the entity being exported.

protected array<string|int, mixed> $ids = []

$isMergeSameAddress

Should contacts with the same address be merged.

protected bool $isMergeSameAddress = \FALSE

$isMergeSameHousehold

Is the contact being merged into a single household.

protected bool $isMergeSameHousehold

$isPostalableOnly

Only export contacts that can receive postal mail.

protected bool $isPostalableOnly

Includes being alive, having an address & not having do_not_mail.

$outputSpecification

protected array<string|int, mixed> $outputSpecification = []

$queryFields

Array of fields in the main query.

protected array<string|int, mixed> $queryFields = []

$relatedContactValues

Export values for related contacts.

protected array<string|int, mixed> $relatedContactValues = []

$relationshipReturnProperties

Array of properties to retrieve for relationships.

protected array<string|int, mixed> $relationshipReturnProperties = []

$relationshipTypes

Key representing the head of household in the relationship array.

protected array<string|int, mixed> $relationshipTypes = []

e.g. ['8_b_a' => 'Household Member Is', '8_a_b = 'Household Member Of'.....]

$requestedFields

Requested output fields.

protected array<string|int, mixed>|null $requestedFields

If set to NULL then it is 'primary fields only' which actually means pretty close to all fields!

$returnProperties

protected array<string|int, mixed> $returnProperties = []

$temporaryTable

Name of a temporary table created to hold the results.

protected string $temporaryTable

Current decision making on when to create a temp table is kinda bad so this might change a bit as it is reviewed but basically we need a temp table or similar to calculate merging addresses. Merging households is handled in php. We create a temp table even when we don't need them.

Methods

__construct()

CRM_Export_BAO_ExportProcessor constructor.

public __construct(int $exportMode, array<string|int, mixed>|null $requestedFields, string $queryOperator[, bool $isMergeSameHousehold = FALSE ][, bool $isPostalableOnly = FALSE ][, bool $isMergeSameAddress = FALSE ][, array<string|int, mixed> $formValues = [] ]) : mixed
Parameters
$exportMode : int
$requestedFields : array<string|int, mixed>|null
$queryOperator : string
$isMergeSameHousehold : bool = FALSE
$isPostalableOnly : bool = FALSE
$isMergeSameAddress : bool = FALSE
$formValues : array<string|int, mixed> = []

Values from the export options form on contact export. We currently support these keys

  • postal_greeting
  • postal_other
  • addresee_greeting
  • addressee_other

addOutputSpecification()

Add a row to the specification for how to output data.

public addOutputSpecification(string $key[, string $relationshipType = NULL ][, string $locationType = NULL ][, int $entityTypeID = NULL ]) : mixed
Parameters
$key : string
$relationshipType : string = NULL
$locationType : string = NULL
$entityTypeID : int = NULL

phone_type_id or provider_id for phone or im fields.

buildMasterCopyArray()

Build array for merging same addresses.

public buildMasterCopyArray(string $sql) : mixed
Parameters
$sql : string

buildRow()

Build the row for output.

public buildRow(CRM_Contact_BAO_Query $query, CRM_Core_DAO $iterationDAO, array<string|int, mixed> $outputColumns, mixed $paymentDetails, mixed $addPaymentHeader) : array<string|int, mixed>|bool
Parameters
$query : CRM_Contact_BAO_Query
$iterationDAO : CRM_Core_DAO
$outputColumns : array<string|int, mixed>
$paymentDetails : mixed
$addPaymentHeader : mixed
Return values
array<string|int, mixed>|bool

createTempTable()

Create the temporary table for output.

public createTempTable() : mixed

defaultReturnProperty()

Get default return property for export based on mode

public defaultReturnProperty() : string
Return values
string

Default Return property

determineReturnProperties()

Determine the required return properties from the input parameters.

public determineReturnProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>

fetchRelationshipDetails()

Get the values of linked household contact.

public fetchRelationshipDetails(CRM_Core_DAO $relDAO, array<string|int, mixed> $value, string $field, array<string|int, mixed> &$row) : mixed
Parameters
$relDAO : CRM_Core_DAO
$value : array<string|int, mixed>
$field : string
$row : array<string|int, mixed>
Tags
throws
Exception

getAdditionalFieldsForPostalExport()

Get additional fields required to do a postal export.

public getAdditionalFieldsForPostalExport() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAdditionalFieldsForSameAddressMerge()

Get additional non-visible fields for address merge purposes.

public getAdditionalFieldsForSameAddressMerge() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAdditionalRequestedReturnProperties()

Get additional return properties.

public getAdditionalRequestedReturnProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>

getAdditionalReturnProperties()

Get array of fields to return, over & above those defined in the main contact exportable fields.

public getAdditionalReturnProperties() : array<string|int, mixed>

These include export mode specific fields & some fields apparently required as 'exportableFields' but not returned by the function of the same name.

Return values
array<string|int, mixed>

Array of fields to return in the format ['field_name' => 1,...]

getAddresseeGreetingTemplate()

public getAddresseeGreetingTemplate() : mixed

getComponentClause()

public getComponentClause() : string
Return values
string

getComponentPaymentFields()

Get fields that indicate payment fields have been requested for a component.

public getComponentPaymentFields() : array<string|int, mixed>

Ideally this should be protected but making it temporarily public helps refactoring..

Return values
array<string|int, mixed>

getComponentTable()

public getComponentTable() : string
Return values
string

getDefaultReturnProperties()

Get the default properties when not specified.

public getDefaultReturnProperties() : array<string|int, mixed>

In the UI this appears as 'Primary fields only' but in practice it's most of the kitchen sink and the hallway closet thrown in.

Since CRM-952 custom fields are excluded, but no other form of mercy is shown.

Return values
array<string|int, mixed>

getExportFileName()

Get the name for the export file.

public getExportFileName() : string
Return values
string

getExportStructureArrays()

Get the various arrays that we use to structure our output.

public getExportStructureArrays() : array<string|int, mixed>

The extraction of these has been moved to a separate function for clarity and so that tests can be added - in particular on the $outputHeaders array.

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.

Return values
array<string|int, mixed>
  • outputColumns Array of columns to be exported. The values don't matter but the key must match the alias for the field generated by BAO_Query object.
  • headerRows Array of the column header strings to put in the csv header - non-associative.
  • sqlColumns Array of column names for the temp table. Not too sure why outputColumns can't be used here.
  • metadata Array of fields with specific parameters to pass to the translate function or another hacky nasty solution I'm too embarassed to discuss here. The keys need
  • to match the outputColumns keys (yes, the fact we ignore the output columns values & then pass another array with values we could use does suggest further refactors. However, you future improver, do remember that every check you do in the main DAO loop is done once per row & that coule be 100,000 times.) Finally a pop quiz: We need the translate context because we use a function other than ts() - is this because
  • a) the function used is more efficient or
  • b) this code is old & outdated. Submit your answers to circular bin or better yet find a way to comment them for posterity.

getGroupBy()

public getGroupBy(object $query) : string
Parameters
$query : object

CRM_Contact_BAO_Query

Return values
string

Group By Clause

getHeaderForRow()

Get the label for the header row based on the field to output.

public getHeaderForRow(string $field) : string
Parameters
$field : string
Return values
string

getHeaderRows()

public getHeaderRows() : array<string|int, mixed>
Return values
array<string|int, mixed>

getHouseholdMergeTypeForRow()

If this row has a household whose details we should use get the relationship type key.

public getHouseholdMergeTypeForRow(mixed $contactID) : bool
Parameters
$contactID : mixed
Return values
bool

getHouseholdRelationshipTypes()

Return relationship types for household merge.

public getHouseholdRelationshipTypes() : mixed

getIds()

public getIds() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMetadata()

public getMetadata() : array<string|int, mixed>
Return values
array<string|int, mixed>

getMetaDataForField()

Get the metadata for the given field.

public getMetaDataForField(mixed $key) : array<string|int, mixed>
Parameters
$key : mixed
Return values
array<string|int, mixed>

getMungedFieldName()

Get the munged field name.

public getMungedFieldName(string $field) : string
Parameters
$field : string
Return values
string

getPaymentHeaders()

Get headers for payment fields.

public getPaymentHeaders() : mixed

Returns an array of contribution fields when the entity supports payment fields and specific fields are not specified. This is a transitional function for refactoring legacy code.

getPaymentTableID()

Get the name of the id field in the table that connects contributions to the export entity.

public getPaymentTableID() : mixed

getPostalGreetingTemplate()

public getPostalGreetingTemplate() : mixed

getPreview()

Preview export output.

public getPreview(int $limit) : array<string|int, mixed>
Parameters
$limit : int
Return values
array<string|int, mixed>

getQueryFields()

public getQueryFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getQueryOperator()

public getQueryOperator() : string
Return values
string

getRelatedHouseholdID()

Get the id of the related household.

public getRelatedHouseholdID(int $contactID, string $relationshipType) : int
Parameters
$contactID : int
$relationshipType : string
Return values
int

getRelationshipReturnProperties()

Get return properties by relationship.

public getRelationshipReturnProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRelationshipTypes()

public getRelationshipTypes() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRelationshipValue()

Get the value for a relationship type field.

public getRelationshipValue(string $relationshipType, int $contactID, string $field) : string

In this case we are building up an array of properties for a related contact.

These may be used for direct exporting or for merge to household depending on the options selected.

Parameters
$relationshipType : string
$contactID : int
$field : string
Return values
string

getRequestedFields()

public getRequestedFields() : array<string|int, mixed>|null
Return values
array<string|int, mixed>|null

getReturnProperties()

public getReturnProperties() : array<string|int, mixed>
Return values
array<string|int, mixed>

getSqlColumnDefinition()

Get the sql column definition for the given field.

public getSqlColumnDefinition(string $fieldName, string $columnName) : mixed
Parameters
$fieldName : string
$columnName : string

getSQLColumns()

public getSQLColumns() : array<string|int, mixed>
Return values
array<string|int, mixed>

getTemporaryTable()

public getTemporaryTable() : string
Return values
string

getTransformedFieldValue()

public getTransformedFieldValue(mixed $field, mixed $iterationDAO, mixed $fieldValue, mixed $paymentDetails) : string
Parameters
$field : mixed
$iterationDAO : mixed
$fieldValue : mixed
$paymentDetails : mixed
Tags
throws
CRM_Core_Exception
Return values
string

getValidLocationFields()

Get the default location fields to request.

public getValidLocationFields() : array<string|int, mixed>
Return values
array<string|int, mixed>

getWhereParams()

Get params for the where criteria.

public getWhereParams() : mixed

isExportPaymentFields()

Should payment fields be appended to the export.

public isExportPaymentFields() : mixed

(This is pretty hacky so hopefully this function won't last long - notice how obviously it should be part of the above function!).

isExportSpecifiedPaymentFields()

Has specific payment fields been requested (as opposed to via all fields).

public isExportSpecifiedPaymentFields() : bool

If specific fields have been requested then they get added at various points.

Return values
bool

isHouseholdExported()

Has the household already been exported.

public isHouseholdExported(int $housholdContactID) : bool
Parameters
$housholdContactID : int
Return values
bool

isHouseholdMergeRelationshipTypeKey()

public isHouseholdMergeRelationshipTypeKey(mixed $fieldName) : bool
Parameters
$fieldName : mixed
Return values
bool

isMergeSameAddress()

Should contacts with the same address be merged.

public isMergeSameAddress() : bool
Return values
bool

isMergeSameHousehold()

public isMergeSameHousehold() : bool
Return values
bool

isPostalableOnly()

public isPostalableOnly() : bool
Return values
bool

isRelationshipTypeKey()

public isRelationshipTypeKey(mixed $fieldName) : bool
Parameters
$fieldName : mixed
Return values
bool

markHouseholdExported()

Mark the given household as already exported.

public markHouseholdExported(mixed $householdID) : mixed
Parameters
$householdID : mixed

mergeSameAddress()

Merge contacts with the same address.

public mergeSameAddress() : mixed

replaceMergeTokens()

Replace contact greetings in merged contacts.

public replaceMergeTokens(int $contactID) : array<string|int, mixed>
Parameters
$contactID : int
Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

runQuery()

public runQuery(mixed $params, mixed $order) : array<string|int, mixed>
Parameters
$params : mixed
$order : mixed
Return values
array<string|int, mixed>

setAdditionalFieldsForPostalExport()

Set additional fields required for a postal export.

public setAdditionalFieldsForPostalExport() : mixed

setAdditionalFieldsForSameAddressMerge()

Set additional non-visible fields for address merge purposes.

public setAdditionalFieldsForSameAddressMerge() : mixed

setAdditionalRequestedReturnProperties()

Set additional return properties.

public setAdditionalRequestedReturnProperties(array<string|int, mixed> $value) : mixed
Parameters
$value : array<string|int, mixed>

setAddresseeGreetingTemplate()

public setAddresseeGreetingTemplate(mixed $addresseeGreetingTemplate) : mixed
Parameters
$addresseeGreetingTemplate : mixed

setColumnAsCalculationOnly()

Mark a column as only required for calculations.

public setColumnAsCalculationOnly(string $column) : mixed

Do not include the row with headers.

Parameters
$column : string

setComponentClause()

public setComponentClause(string $componentClause) : mixed
Parameters
$componentClause : string

setComponentTable()

Set the component table (if any).

public setComponentTable(string $componentTable) : mixed
Parameters
$componentTable : string

setExportMode()

public setExportMode(int $exportMode) : mixed
Parameters
$exportMode : int

setGreetingOptions()

Set the greeting options, if relevant.

public setGreetingOptions() : mixed

setHouseholdMergeReturnProperties()

Add the main return properties to the household merge properties if needed for merging.

public setHouseholdMergeReturnProperties() : mixed

If we are using household merge we need to add these to the relationship properties to be retrieved.

setIds()

public setIds(array<string|int, mixed> $ids) : mixed
Parameters
$ids : array<string|int, mixed>

setIsMergeSameAddress()

Set same address is to be merged.

public setIsMergeSameAddress(bool $isMergeSameAddress) : mixed
Parameters
$isMergeSameAddress : bool

setIsMergeSameHousehold()

public setIsMergeSameHousehold(bool $isMergeSameHousehold) : mixed
Parameters
$isMergeSameHousehold : bool

setIsPostalableOnly()

public setIsPostalableOnly(bool $isPostalableOnly) : mixed
Parameters
$isPostalableOnly : bool

setPostalGreetingTemplate()

public setPostalGreetingTemplate(mixed $postalGreetingTemplate) : mixed
Parameters
$postalGreetingTemplate : mixed

setQueryFields()

public setQueryFields(array<string|int, mixed> $queryFields) : mixed
Parameters
$queryFields : array<string|int, mixed>

setQueryMode()

Set the query mode based on the export mode.

public setQueryMode() : mixed

setQueryOperator()

public setQueryOperator(string $queryOperator) : mixed
Parameters
$queryOperator : string

setRelationshipReturnProperties()

Add the field to relationship return properties & return it.

public setRelationshipReturnProperties(array<string|int, mixed> $value, string $relationshipKey) : array<string|int, mixed>

This function is doing both setting & getting which is yuck but it is an interim refactor.

Parameters
$value : array<string|int, mixed>
$relationshipKey : string
Return values
array<string|int, mixed>

setRelationshipValue()

Set the value for a relationship type field.

public setRelationshipValue(string $relationshipType, int $contactID, string $field, string $value) : mixed

In this case we are building up an array of properties for a related contact.

These may be used for direct exporting or for merge to household depending on the options selected.

Parameters
$relationshipType : string
$contactID : int
$field : string
$value : string

setRequestedFields()

public setRequestedFields(array<string|int, mixed>|null $requestedFields) : mixed
Parameters
$requestedFields : array<string|int, mixed>|null

setReturnProperties()

public setReturnProperties(array<string|int, mixed> $returnProperties) : mixed
Parameters
$returnProperties : array<string|int, mixed>

setSqlColumnDefn()

public setSqlColumnDefn(mixed $key) : mixed
Parameters
$key : mixed

setTemporaryTable()

public setTemporaryTable(string $temporaryTable) : mixed
Parameters
$temporaryTable : string

trimNonTokensFromAddressString()

The function unsets static part of the string, if token is the dynamic part.

public trimNonTokensFromAddressString(string &$parsedString, string $defaultGreeting, string $greetingLabel) : mixed

Example: 'Hello {contact.first_name}' => converted to => '{contact.first_name}' i.e 'Hello Alan' => converted to => 'Alan'

Parameters
$parsedString : string
$defaultGreeting : string
$greetingLabel : string

writeCSVFromTable()

Write to the csv from the temp table.

public writeCSVFromTable() : mixed

buildRelationshipFieldsForRow()

protected buildRelationshipFieldsForRow(mixed &$row, mixed $contactID, mixed $value, mixed $field) : mixed
Parameters
$row : mixed
$contactID : mixed
$value : mixed
$field : mixed

cacheContactGreetings()

Cache the greeting fields for the given contact.

protected cacheContactGreetings(int $contactID) : mixed
Parameters
$contactID : int

getContactGreeting()

Get the greeting value for the given contact.

protected getContactGreeting(int $contactID, string $type, string $default) : string

The values have already been cached so we are grabbing the value at this point.

Parameters
$contactID : int
$type : string

postal_greeting|addressee|email_greeting

$default : string
Return values
string

getContactPortionOfGreeting()

Get the portion of the greeting string that relates to the contact.

protected getContactPortionOfGreeting(int $contactID, int $greetingID, string $type, string $defaultGreeting) : mixed|string

For example if the greeting id 'Dear Sarah' we are going to combine it with 'Dear Mike' so we want to strip the 'Dear ' and just get 'Sarah

Parameters
$contactID : int
$greetingID : int
$type : string

postal_greeting, addressee (email_greeting not currently implemented for unknown reasons.

$defaultGreeting : string
Return values
mixed|string

getOutputSpecificationFieldKey()

Get the mysql field name key.

protected getOutputSpecificationFieldKey(string $key, mixed $relationshipType, mixed $locationType, mixed $entityLabel) : string

This key is locked in by tests but the reasons for the specific conventions - ie. headings are used for keying fields in some cases, are likely accidental rather than deliberate.

This key is used for the output sql array.

Parameters
$key : string
$relationshipType : mixed
$locationType : mixed
$entityLabel : mixed
Return values
string

getOutputSpecificationIndex()

In order to respect the history of this class we need to index kinda illogically.

protected getOutputSpecificationIndex(string $key, string $relationshipType, string $locationType, mixed $entityLabel) : string

On the bright side - this stuff is tested within a nano-byte of it's life.

e.g '2-a-b_Home-City'

Parameters
$key : string
$relationshipType : string
$locationType : string
$entityLabel : mixed
Return values
string

getOutputSpecificationLabel()

Get the compiled label for the column.

protected getOutputSpecificationLabel(string $key, string $relationshipType, string $locationType, string $entityLabel) : string

e.g 'Gender', 'Employee Of-Home-city'

Parameters
$key : string
$relationshipType : string
$locationType : string
$entityLabel : string
Return values
string

hasRequestedComponentPaymentFields()

Have component payment fields been requested.

protected hasRequestedComponentPaymentFields() : bool
Return values
bool

instantiateTempTable()

Set up the temp table.

protected instantiateTempTable(array<string|int, mixed> $headerRows) : mixed
Parameters
$headerRows : array<string|int, mixed>

isHouseholdToSkip()

Is this contact a household that is already set to be exported by virtue of it's household members.

protected isHouseholdToSkip(int $contactID) : bool
Parameters
$contactID : int
Return values
bool

setGreetingStringsForSameAddressMerge()

Set the template strings to be used when merging two contacts with the same address.

protected setGreetingStringsForSameAddressMerge(array<string|int, mixed> $formValues) : mixed
Parameters
$formValues : array<string|int, mixed>

Values from first form. In this case we care about the keys

  • postal_greeting
  • postal_other
  • address_greeting
  • addressee_other

writeRows()

Write rows to the csv.

protected writeRows(array<string|int, mixed> $headerRows, array<string|int, mixed> $rows) : mixed
Parameters
$headerRows : array<string|int, mixed>
$rows : array<string|int, mixed>

        
On this page

Search results