protected function Sql::getFieldSchema in Drupal 10
Same name and namespace in other branches
- 8 core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::getFieldSchema()
- 9 core/modules/migrate/src/Plugin/migrate/id_map/Sql.php \Drupal\migrate\Plugin\migrate\id_map\Sql::getFieldSchema()
Creates schema from an ID definition.
Parameters
array $id_definition: The definition of the field having the structure as the items returned by MigrateSourceInterface or MigrateDestinationInterface::getIds().
Return value
array The database schema definition.
See also
\Drupal\migrate\Plugin\MigrateSourceInterface::getIds()
\Drupal\migrate\Plugin\MigrateDestinationInterface::getIds()
1 call to Sql::getFieldSchema()
- Sql::ensureTables in core/
modules/ migrate/ src/ Plugin/ migrate/ id_map/ Sql.php - Create the map and message tables if they don't already exist.
1 method overrides Sql::getFieldSchema()
- TestSqlIdMap::getFieldSchema in core/
modules/ migrate/ tests/ src/ Unit/ TestSqlIdMap.php - Gets the field schema.
File
- core/
modules/ migrate/ src/ Plugin/ migrate/ id_map/ Sql.php, line 500
Class
- Sql
- Defines the sql based ID map implementation.
Namespace
Drupal\migrate\Plugin\migrate\id_mapCode
protected function getFieldSchema(array $id_definition) {
$type_parts = explode('.', $id_definition['type']);
if (count($type_parts) == 1) {
$type_parts[] = 'value';
}
unset($id_definition['type']);
// Get the field storage definition.
$definition = BaseFieldDefinition::create($type_parts[0]);
// Get a list of setting keys belonging strictly to the field definition.
$default_field_settings = $definition
->getSettings();
// Separate field definition settings from custom settings. Custom settings
// are settings passed in $id_definition that are not part of field storage
// definition settings.
$field_settings = array_intersect_key($id_definition, $default_field_settings);
$custom_settings = array_diff_key($id_definition, $default_field_settings);
// Resolve schema from field storage definition settings.
$schema = $definition
->setSettings($field_settings)
->getColumns()[$type_parts[1]];
// Merge back custom settings.
return $schema + $custom_settings;
}