function MigrateSourceInterface::getIds
Same name in other branches
- 9 core/modules/migrate/src/Plugin/MigrateSourceInterface.php \Drupal\migrate\Plugin\MigrateSourceInterface::getIds()
- 8.9.x core/modules/migrate/src/Plugin/MigrateSourceInterface.php \Drupal\migrate\Plugin\MigrateSourceInterface::getIds()
- 11.x core/modules/migrate/src/Plugin/MigrateSourceInterface.php \Drupal\migrate\Plugin\MigrateSourceInterface::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:
return [
'id' => [
'type' => 'integer',
'unsigned' => FALSE,
'size' => 'big',
],
'version' => [
'type' => 'string',
'max_length' => 64,
'is_ascii' => TRUE,
],
];
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:
return [
'format' => [
'type' => 'text.format',
],
];
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.
return [
'nid' => [
'type' => 'integer',
'alias' => 'n',
],
];
See also
\Drupal\Core\Field\FieldStorageDefinitionInterface::getSettings()
\Drupal\Core\Field\Plugin\Field\FieldType\IntegerItem
\Drupal\Core\Field\Plugin\Field\FieldType\StringItem
\Drupal\text\Plugin\Field\FieldType\TextItem
\Drupal\migrate\Plugin\migrate\source\SqlBase
3 calls to MigrateSourceInterface::getIds()
- SourcePluginBase::next in core/
modules/ migrate/ src/ Plugin/ migrate/ source/ SourcePluginBase.php - SqlBase::initializeIterator in core/
modules/ migrate/ src/ Plugin/ migrate/ source/ SqlBase.php - Initializes the iterator with the source data.
- SqlBase::mapJoinable in core/
modules/ migrate/ src/ Plugin/ migrate/ source/ SqlBase.php - Checks if we can join against the map table.
87 methods override MigrateSourceInterface::getIds()
- Action::getIds in core/
modules/ system/ src/ Plugin/ migrate/ source/ Action.php - Defines the source fields uniquely identifying a source row.
- Block::getIds in core/
modules/ block/ src/ Plugin/ migrate/ source/ Block.php - Defines the source fields uniquely identifying a source row.
- BlockCustom::getIds in core/
modules/ block_content/ src/ Plugin/ migrate/ source/ d7/ BlockCustom.php - Defines the source fields uniquely identifying a source row.
- BlockCustomTranslation::getIds in core/
modules/ block_content/ src/ Plugin/ migrate/ source/ d7/ BlockCustomTranslation.php - Defines the source fields uniquely identifying a source row.
- BlockedIps::getIds in core/
modules/ ban/ src/ Plugin/ migrate/ source/ d7/ BlockedIps.php - Defines the source fields uniquely identifying a source row.
File
-
core/
modules/ migrate/ src/ Plugin/ MigrateSourceInterface.php, line 114
Class
- MigrateSourceInterface
- Defines an interface for migrate sources.
Namespace
Drupal\migrate\PluginCode
public function getIds();
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.