interface MigrateSourceInterface implements Countable, Iterator, PluginInspectionInterface (View source)

Defines an interface for migrate sources.

Constants

NOT_COUNTABLE

Indicates that the source is not countable.

Methods

string
getPluginId()

Gets the plugin_id of the plugin instance.

array
getPluginDefinition()

Gets the definition of the plugin implementation.

array
fields()

Returns available fields on the source.

bool
prepareRow(Row $row)

Adds additional data to the row.

__toString()

Allows class to decide how it will react when it is treated like a string.

array[]
getIds()

Defines the source fields uniquely identifying a source row.

string|null
getSourceModule()

Gets the source module providing the source data.

Details

string getPluginId()

Gets the plugin_id of the plugin instance.

Return Value

string

The plugin_id of the plugin instance.

array getPluginDefinition()

Gets the definition of the plugin implementation.

Return Value

array

The plugin definition, as returned by the discovery object used by the plugin manager.

array fields()

Returns available fields on the source.

Return Value

array

Available fields in the source, keys are the field machine names as used in field mappings, values are descriptions.

bool prepareRow(Row $row)

Adds additional data to the row.

Parameters

Row $row

The row object.

Return Value

bool

FALSE if this row needs to be skipped.

__toString()

Allows class to decide how it will react when it is treated like a string.

array[] getIds()

Defines the source fields uniquely identifying a source row.

None of these fields should contain a NULL value. If necessary, use prepareRow() or hook_migrate_prepare_row() to rewrite NULL values to appropriate empty values (such as '' or 0).

Return Value

array[]

An associative array of field definitions keyed by field ID. Values are associative arrays with a structure that contains the field type ('type' key). The other keys are the field storage settings as they are returned by FieldStorageDefinitionInterface::getSettings().

Examples:

A composite source primary key that is defined by an integer and a string might look like this: @code return [ 'id' => [ 'type' => 'integer', 'unsigned' => FALSE, 'size' => 'big', ], 'version' => [ 'type' => 'string', 'max_length' => 64, 'is_ascii' => TRUE, ], ]; @endcode

If 'type' points to a field plugin with multiple columns and needs to refer to a column different than 'value', the key of that column will be appended as a suffix to the plugin name, separated by dot ('.'). Example: @code return [ 'format' => [ 'type' => 'text.format', ], ]; @endcode

Additional custom keys/values that are not part of field storage definition can be added as shown below. The most common setting passed along to the ID definition is table 'alias', used by the SqlBase source plugin in order to distinguish between ambiguous column names - for example, when a SQL source query joins two tables with the same column names. @code return [ 'nid' => [ 'type' => 'integer', 'alias' => 'n', ], ]; @endcode

See also

FieldStorageDefinitionInterface::getSettings
IntegerItem
StringItem
TextItem
SqlBase

string|null getSourceModule()

Gets the source module providing the source data.

Return Value

string|null

The source module or NULL if not found.