public function BeerTerm::getIds in Migrate Plus 8.2
Same name and namespace in other branches
- 8.5 migrate_example/src/Plugin/migrate/source/BeerTerm.php \Drupal\migrate_example\Plugin\migrate\source\BeerTerm::getIds()
- 8 migrate_example/src/Plugin/migrate/source/BeerTerm.php \Drupal\migrate_example\Plugin\migrate\source\BeerTerm::getIds()
- 8.3 migrate_example/src/Plugin/migrate/source/BeerTerm.php \Drupal\migrate_example\Plugin\migrate\source\BeerTerm::getIds()
- 8.4 migrate_example/src/Plugin/migrate/source/BeerTerm.php \Drupal\migrate_example\Plugin\migrate\source\BeerTerm::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',
],
];
Overrides MigrateSourceInterface::getIds
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
File
- migrate_example/
src/ Plugin/ migrate/ source/ BeerTerm.php, line 68
Class
- BeerTerm
- This is an example of a simple SQL-based source plugin. Source plugins are classes which deliver source data to the processing pipeline. For SQL sources, the SqlBase class provides most of the functionality needed - for a specific migration, you are…
Namespace
Drupal\migrate_example\Plugin\migrate\sourceCode
public function getIds() {
/**
* This method indicates what field(s) from the source row uniquely identify
* that source row, and what their types are. This is critical information
* for managing the migration. The keys of the returned array are the field
* names from the query which comprise the unique identifier. The values are
* arrays indicating the type of the field, used for creating compatible
* columns in the map tables that track processed items.
*/
return [
'style' => [
'type' => 'string',
// 'alias' is the alias for the table containing 'style' in the query
// defined above. Optional in this case, but necessary if the same
// column may occur in multiple tables in a join.
'alias' => 'met',
],
];
}