class SmartSql in Smart SQL ID Map 1.1.x
Same name and namespace in other branches
- 1.0.x src/Plugin/migrate/id_map/SmartSql.php \Drupal\smart_sql_idmap\Plugin\migrate\id_map\SmartSql
A smart, sql based ID map.
@todo Provide an upgrade path when https://drupal.org/i/2845340 gets fixed.
Plugin annotation
@PluginID("smart_sql");
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\migrate\Plugin\migrate\id_map\Sql implements ContainerFactoryPluginInterface, HighestIdInterface, MigrateIdMapInterface
- class \Drupal\smart_sql_idmap\Plugin\migrate\id_map\SmartSql
- class \Drupal\migrate\Plugin\migrate\id_map\Sql implements ContainerFactoryPluginInterface, HighestIdInterface, MigrateIdMapInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of SmartSql
2 files declare their use of SmartSql
- SmartSqlMigrateExecutableTest.php in tests/
src/ Kernel/ SmartSqlMigrateExecutableTest.php - TestSmartSqlIdMap.php in tests/
src/ Unit/ TestSmartSqlIdMap.php
File
- src/
Plugin/ migrate/ id_map/ SmartSql.php, line 17
Namespace
Drupal\smart_sql_idmap\Plugin\migrate\id_mapView source
class SmartSql extends Sql {
/**
* {@inheritdoc}
*
* @see https://drupal.org/i/2845340
*/
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher) {
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration, $event_dispatcher);
// Default generated table names, limited to 63 characters.
$machine_name = str_replace(PluginBase::DERIVATIVE_SEPARATOR, '__', $this->migration
->id());
$prefix_length = strlen($this->database
->tablePrefix());
$map_table_name = 'm_map_' . mb_strtolower($machine_name);
$this->mapTableName = mb_substr($map_table_name, 0, 63 - $prefix_length) === $map_table_name ? $map_table_name : mb_substr($map_table_name, 0, 45 - $prefix_length) . '_' . substr(md5($machine_name), 0, 17);
$message_table_name = 'm_message_' . mb_strtolower($machine_name);
$this->messageTableName = mb_substr($message_table_name, 0, 63 - $prefix_length) === $message_table_name ? $message_table_name : mb_substr($message_table_name, 0, 45 - $prefix_length) . '_' . substr(md5($machine_name), 0, 17);
}
/**
* {@inheritdoc}
*
* @see https://drupal.org/i/3227549
* @see https://drupal.org/i/3227660
*/
public function getRowByDestination(array $destination_id_values) {
$missing_destination_keys = array_diff(array_keys($this
->destinationIdFields()), array_keys($destination_id_values));
// Fix for https://drupal.org/i/3227549.
$result = $missing_destination_keys ? NULL : parent::getRowByDestination($destination_id_values);
// Fix for https://drupal.org/i/3227549 and workaround for
// https://drupal.org/i/3227660.
return $result ? $result : [
'rollback_action' => 99999,
];
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
protected | property | ||
DependencySerializationTrait:: |
public | function | 2 | |
DependencySerializationTrait:: |
public | function | 2 | |
MessengerTrait:: |
protected | property | The messenger. | 27 |
MessengerTrait:: |
public | function | Gets the messenger. | 27 |
MessengerTrait:: |
public | function | Sets the messenger. | |
MigrateIdMapInterface:: |
constant | Indicates that the data for the row is to be deleted. | ||
MigrateIdMapInterface:: |
constant | Indicates that the data for the row is to be preserved. | ||
MigrateIdMapInterface:: |
constant | Indicates that the import of the row failed. | ||
MigrateIdMapInterface:: |
constant | Indicates that the import of the row was ignored. | ||
MigrateIdMapInterface:: |
constant | Indicates that the import of the row was successful. | ||
MigrateIdMapInterface:: |
constant | Indicates that the row needs to be updated. | ||
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
2 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
SmartSql:: |
public | function |
Overrides Sql:: |
|
SmartSql:: |
public | function |
Overrides Sql:: |
1 |
Sql:: |
protected | property | The current key. | |
Sql:: |
protected | property | The current row. | |
Sql:: |
protected | property | The database connection for the map/message tables on the destination. | |
Sql:: |
protected | property | The destination ID fields. | |
Sql:: |
protected | property | The destination identifiers. | |
Sql:: |
protected | property | An event dispatcher instance to use for map events. | |
Sql:: |
protected | property | Whether the plugin is already initialized. | |
Sql:: |
protected | property | The migration map table name. | |
Sql:: |
protected | property | The migrate message service. | 1 |
Sql:: |
protected | property | The message table name. | |
Sql:: |
protected | property | The migration being done. | |
Sql:: |
protected | property | The select query. | |
Sql:: |
protected | property | The result. | |
Sql:: |
protected | property | The source ID fields. | |
Sql:: |
protected | property | The source identifiers. | |
Sql:: |
public | function |
Clears all messages from the map. Overrides MigrateIdMapInterface:: |
|
Sql:: |
protected | function | Counts records in a table. | |
Sql:: |
public static | function |
Creates an instance of the plugin. Overrides ContainerFactoryPluginInterface:: |
|
Sql:: |
public | function | Implementation of \Iterator::current(). | |
Sql:: |
public | function |
Looks up the destination identifier currently being iterated. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function |
Looks up the source identifier(s) currently being iterated. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function |
Deletes the map and message entries for a given source record. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function |
Deletes the map and message table entries for a given destination row. Overrides MigrateIdMapInterface:: |
|
Sql:: |
protected | function | The destination ID fields. | |
Sql:: |
public | function |
Removes any persistent storage used by this map. Overrides MigrateIdMapInterface:: |
|
Sql:: |
protected | function | Create the map and message tables if they don't already exist. | 1 |
Sql:: |
public | function |
Returns the number of items that failed to import. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function | Gets the database connection. | 1 |
Sql:: |
protected | function | Creates schema from an ID definition. | 1 |
Sql:: |
public | function |
Returns the highest ID tracked by the implementing plugin. Overrides HighestIdInterface:: |
|
Sql:: |
public | function |
Retrieves a traversable object of messages related to source records. Overrides MigrateIdMapInterface:: |
|
Sql:: |
protected | function | Returns the migration plugin manager. | |
Sql:: |
public | function |
Get the fully qualified map table name. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function |
Retrieves a row from the map table based on source identifier values. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function |
Retrieves an array of map rows marked as needing update. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function | Retrieves the hash of the source identifier values. | |
Sql:: |
public | function |
Returns the number of imported items in the map. Overrides MigrateIdMapInterface:: |
|
Sql:: |
protected | function | Initialize the plugin. | |
Sql:: |
public | function | Implementation of \Iterator::key(). | |
Sql:: |
public | function |
Looks up the destination identifiers corresponding to a source key. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function |
Looks up the source identifier. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function | The name of the database map table. | |
Sql:: |
public | function |
Returns the number of messages saved. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function | The name of the database message table. | |
Sql:: |
public | function | Implementation of \Iterator::next(). | |
Sql:: |
public | function |
Prepares to run a full update. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function |
Returns the number of processed items in the map. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function | Implementation of \Iterator::rewind(). | |
Sql:: |
public | function |
Saves a mapping from the source identifiers to the destination identifiers. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function |
Saves a message related to a source record in the migration message table. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function |
Sets the migrate message service. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function |
Sets a specified record to be updated, if it exists. Overrides MigrateIdMapInterface:: |
|
Sql:: |
protected | function | The source ID fields. | |
Sql:: |
constant | Column name of hashed source id values. | ||
Sql:: |
public | function |
Returns a count of items which are marked as needing update. Overrides MigrateIdMapInterface:: |
|
Sql:: |
public | function | Implementation of \Iterator::valid(). | |
StringTranslationTrait:: |
protected | property | The string translation service. | 4 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |