Documentation

DataSourceInterface

Objects that implement the DataSource interface can be used in CiviCRM imports.

Table of Contents

Methods

buildQuickForm()  : void
This is function is called by the form object to get the DataSource's form snippet.
checkPermission()  : bool
Determine if the current user has access to this data source.
getColumnHeaders()  : array<string|int, mixed>
Get an array of column headers, if any.
getInfo()  : array<string|int, mixed>
Provides information about the data source.
getRows()  : array<string|int, mixed>
Get rows as an array.
getSubmittableFields()  : array<string|int, mixed>
Get array array of field names that may be submitted for this data source.
initialize()  : void
Initialize the datasource, based on the submitted values stored in the user job.
purge()  : array<string|int, mixed>
Purge any datasource related assets when the datasource is dropped.
setLimit()  : self
setStatuses()  : self
Set the statuses to be retrieved.

Methods

buildQuickForm()

This is function is called by the form object to get the DataSource's form snippet.

public buildQuickForm(CRM_Import_Forms $form) : void

It should add all fields necessary to get the data uploaded to the temporary table in the DB.

Parameters
$form : CRM_Import_Forms

checkPermission()

Determine if the current user has access to this data source.

public checkPermission() : bool
Return values
bool

getColumnHeaders()

Get an array of column headers, if any.

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

This is presented to the user in the MapField screen so that can see what fields they are mapping.

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

getInfo()

Provides information about the data source.

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

Description of this data source, including:

  • title: string, translated, required
  • permissions: array, optional

getRows()

Get rows as an array.

public getRows([bool $nonAssociative = TRUE ]) : array<string|int, mixed>

The array has all values.

Parameters
$nonAssociative : bool = TRUE

Return as a non-associative array?

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

getSubmittableFields()

Get array array of field names that may be submitted for this data source.

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

The quick form for the datasource is added by ajax - meaning that QuickForm does not see them as part of the form. However, any fields listed in this array will be taken from the $_POST and stored to the UserJob under metadata->submitted_values.

Return values
array<string|int, mixed>

initialize()

Initialize the datasource, based on the submitted values stored in the user job.

public initialize() : void

Generally this will include transferring the data to a database table.

Tags
throws
CRM_Core_Exception

purge()

Purge any datasource related assets when the datasource is dropped.

public purge([array<string|int, mixed> $newParams = [] ]) : array<string|int, mixed>

This is the datasource's chance to delete any tables etc that it created which will now not be used.

Parameters
$newParams : array<string|int, mixed> = []

If the dataSource is being updated to another variant of the same class (eg. the csv upload was set to no column headers and they have resubmitted WITH skipColumnHeader (first row is a header) then the dataSource is still CSV and the params for the new instance are passed in. When changing from csv to SQL (for example) newParams is empty.

Tags
throws
CRM_Core_Exception
Return values
array<string|int, mixed>

The details to update the DataSource key in the userJob metadata to. Generally and empty array but it the datasource decided (for example) that the table it created earlier is still consistent with the new params then it might decided not to drop the table and would want to retain some metadata.

setLimit()

public setLimit(int $limit) : self
Parameters
$limit : int
Return values
self

setStatuses()

Set the statuses to be retrieved.

public setStatuses(array<string|int, mixed> $statuses) : self
Parameters
$statuses : array<string|int, mixed>
Return values
self

        
On this page

Search results