Drupal 8  8.0.2
Sql Class Reference
Inheritance diagram for Sql:

Public Member Functions

 __construct (array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, EventDispatcherInterface $event_dispatcher)
 
 mapTableName ()
 
 messageTableName ()
 
 getQualifiedMapTableName ()
 
 getDatabase ()
 
 setMessage (MigrateMessageInterface $message)
 
 getRowBySource (array $source_id_values)
 
 getRowByDestination (array $destination_id_values)
 
 getRowsNeedingUpdate ($count)
 
 lookupSourceID (array $destination_id_values)
 
 lookupDestinationId (array $source_id_values)
 
 saveIdMapping (Row $row, array $destination_id_values, $source_row_status=MigrateIdMapInterface::STATUS_IMPORTED, $rollback_action=MigrateIdMapInterface::ROLLBACK_DELETE)
 
 saveMessage (array $source_id_values, $message, $level=MigrationInterface::MESSAGE_ERROR)
 
 getMessageIterator (array $source_id_values=[], $level=NULL)
 
 prepareUpdate ()
 
 processedCount ()
 
 importedCount ()
 
 updateCount ()
 
 errorCount ()
 
 messageCount ()
 
 delete (array $source_id_values, $messages_only=FALSE)
 
 deleteDestination (array $destination_id_values)
 
 setUpdate (array $source_id_values)
 
 clearMessages ()
 
 destroy ()
 
 rewind ()
 
 current ()
 
 key ()
 
 currentDestination ()
 
 next ()
 
 valid ()
 
- Public Member Functions inherited from PluginInspectionInterface
 getPluginId ()
 
 getPluginDefinition ()
 

Static Public Member Functions

static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration=NULL)
 
- Static Public Member Functions inherited from ContainerFactoryPluginInterface
static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 

Protected Member Functions

 sourceIdFields ()
 
 destinationIdFields ()
 
 init ()
 
 ensureTables ()
 
 getFieldSchema (array $id_definition)
 
 countHelper ($status, $table=NULL)
 

Protected Attributes

 $eventDispatcher
 
 $mapTableName
 
 $messageTableName
 
 $message
 
 $database
 
 $query
 
 $migration
 
 $sourceIdFields
 
 $destinationIdFields
 
 $initialized
 
 $result = NULL
 
 $sourceIds = array()
 
 $destinationIds = array()
 
 $currentRow = NULL
 
 $currentKey = array()
 

Additional Inherited Members

- Data Fields inherited from MigrateIdMapInterface
const STATUS_IMPORTED = 0
 
const STATUS_NEEDS_UPDATE = 1
 
const STATUS_IGNORED = 2
 
const STATUS_FAILED = 3
 
const ROLLBACK_DELETE = 0
 
const ROLLBACK_PRESERVE = 1
 

Detailed Description

Defines the sql based ID map implementation.

It creates one map and one message table per migration entity to store the relevant information.

("sql")

Constructor & Destructor Documentation

__construct ( array  $configuration,
  $plugin_id,
  $plugin_definition,
MigrationInterface  $migration,
EventDispatcherInterface  $event_dispatcher 
)

Constructs an SQL object.

Sets up the tables and builds the maps,

Parameters
array$configurationThe configuration.
string$plugin_idThe plugin ID for the migration process to do.
mixed$plugin_definitionThe configuration for the plugin.
\Drupal\migrate\Entity\MigrationInterface$migrationThe migration to do.

Member Function Documentation

clearMessages ( )

{Clears all messages from the map.}

Implements MigrateIdMapInterface.

References Sql\getDatabase(), and Sql\messageTableName().

Here is the call graph for this function:

countHelper (   $status,
  $table = NULL 
)
protected

Counts records in a table.

Parameters
int$statusAn integer for the source_row_status column.
string$table(optional) The table to work. Defaults to NULL.
Returns
int The number of records.

References Sql\getDatabase(), and Sql\mapTableName().

Referenced by Sql\errorCount(), Sql\messageCount(), and Sql\updateCount().

Here is the call graph for this function:

Here is the caller graph for this function:

static create ( ContainerInterface  $container,
array  $configuration,
  $plugin_id,
  $plugin_definition,
MigrationInterface  $migration = NULL 
)
static

{}

current ( )

Implementation of Iterator::current().

This is called when entering a loop iteration, returning the current row.

currentDestination ( )

{Looks up the destination identifier currently being iterated.

Returns
array The destination identifier values of the record, or NULL on failure.
}

Implements MigrateIdMapInterface.

References Sql\destinationIdFields(), and Sql\valid().

Here is the call graph for this function:

delete ( array  $source_id_values,
  $messages_only = FALSE 
)

{Deletes the map and message entries for a given source record.

Parameters
array$source_id_valuesThe source identifier keyed values of the record, e.g. ['nid' => 5].
bool$messages_only(optional) TRUE to only delete the migrate messages. Defaults to FALSE.
}

Implements MigrateIdMapInterface.

References Sql\getDatabase(), Sql\mapTableName(), Sql\messageTableName(), and Sql\sourceIdFields().

Here is the call graph for this function:

deleteDestination ( array  $destination_id_values)

{Deletes the map and message table entries for a given destination row.

Parameters
array$destination_id_valuesThe destination identifier key value pairs we should do the deletes for.
}

Implements MigrateIdMapInterface.

References Sql\destinationIdFields(), Sql\getDatabase(), Sql\lookupSourceID(), Sql\mapTableName(), Sql\messageTableName(), and Sql\sourceIdFields().

Here is the call graph for this function:

destinationIdFields ( )
protected

The destination ID fields.

Returns
array The destination ID fields.

Referenced by Sql\currentDestination(), Sql\deleteDestination(), Sql\getRowByDestination(), Sql\lookupDestinationId(), Sql\lookupSourceID(), Sql\rewind(), and Sql\saveIdMapping().

Here is the caller graph for this function:

destroy ( )

{Removes any persistent storage used by this map.For example, remove the map and message tables.}

Implements MigrateIdMapInterface.

References Sql\getDatabase(), Sql\mapTableName(), and Sql\messageTableName().

Here is the call graph for this function:

ensureTables ( )
protected

Create the map and message tables if they don't already exist.

References Sql\getDatabase(), Sql\getFieldSchema(), Sql\mapTableName(), Sql\messageTableName(), MigrateIdMapInterface\ROLLBACK_DELETE, and MigrateIdMapInterface\STATUS_IMPORTED.

Referenced by Sql\init().

Here is the call graph for this function:

Here is the caller graph for this function:

errorCount ( )

{Returns the number of items that failed to import.

Returns
int The number of items that errored out.
}

Implements MigrateIdMapInterface.

References Sql\countHelper().

Here is the call graph for this function:

getDatabase ( )

Gets the database connection.

Returns
The database connection object.

References Drupal\database(), and Sql\init().

Referenced by Sql\clearMessages(), Sql\countHelper(), Sql\delete(), Sql\deleteDestination(), Sql\destroy(), Sql\ensureTables(), Sql\getMessageIterator(), Sql\getQualifiedMapTableName(), Sql\getRowByDestination(), Sql\getRowBySource(), Sql\getRowsNeedingUpdate(), Sql\importedCount(), Sql\init(), Sql\lookupDestinationId(), Sql\lookupSourceID(), Sql\prepareUpdate(), Sql\processedCount(), Sql\rewind(), Sql\saveIdMapping(), Sql\saveMessage(), and Sql\setUpdate().

Here is the call graph for this function:

Here is the caller graph for this function:

getFieldSchema ( array  $id_definition)
protected

Creates schema from an ID definition.

Parameters
array$id_definitionA field schema definition. Can be SQL schema or a type data based schema. In the latter case, the value of type needs to be $typed_data_type.$column.
Returns
array The schema definition.

References BaseFieldDefinition\create().

Referenced by Sql\ensureTables().

Here is the call graph for this function:

Here is the caller graph for this function:

getMessageIterator ( array  $source_id_values = [],
  $level = NULL 
)

{Retrieves an iterator over messages relate to source records.

Parameters
array$source_id_values(optional) The source identifier keyed values of the record, e.g. ['nid' => 5]. If empty (the default), all messages are retrieved.
int$level(optional) Message severity. If NULL (the default), retrieve messages of all severities.
Returns
Retrieves an iterator over the message rows.
}

Implements MigrateIdMapInterface.

References Sql\getDatabase(), Sql\messageTableName(), and Sql\sourceIdFields().

Here is the call graph for this function:

getQualifiedMapTableName ( )

Get the fully qualified map table name.

Returns
string The fully qualified map table name.

Implements MigrateIdMapInterface.

References Sql\getDatabase(), and Sql\mapTableName().

Here is the call graph for this function:

getRowByDestination ( array  $destination_id_values)

{Retrieves a row by the destination identifiers.

Parameters
array$destination_id_valuesThe destination identifier keyed values of the record, e.g. ['nid' => 5].
Returns
array The row(s) of data.
}

Implements MigrateIdMapInterface.

References Sql\destinationIdFields(), Sql\getDatabase(), and Sql\mapTableName().

Here is the call graph for this function:

getRowBySource ( array  $source_id_values)

{Retrieves a row from the map table based on source identifier values.

Parameters
array$source_id_valuesThe source identifier keyed values of the record, e.g. ['nid' => 5].
Returns
array The raw row data as an associative array.
}

Implements MigrateIdMapInterface.

References Sql\getDatabase(), Sql\mapTableName(), and Sql\sourceIdFields().

Here is the call graph for this function:

getRowsNeedingUpdate (   $count)

{Retrieves an array of map rows marked as needing update.

Parameters
int$countThe maximum number of rows to return.
Returns
array Array of map row objects that need updating.
}

Implements MigrateIdMapInterface.

References Sql\getDatabase(), and Sql\mapTableName().

Here is the call graph for this function:

importedCount ( )

{Returns the number of imported items in the map.

Returns
int The number of imported items.
}

Implements MigrateIdMapInterface.

References Sql\getDatabase(), Sql\mapTableName(), and MigrateIdMapInterface\STATUS_IMPORTED.

Here is the call graph for this function:

init ( )
protected

Initialize the plugin.

References Sql\ensureTables(), Sql\getDatabase(), Sql\mapTableName(), Sql\messageTableName(), Unicode\strtolower(), and Unicode\substr().

Referenced by Sql\getDatabase(), Sql\mapTableName(), and Sql\messageTableName().

Here is the call graph for this function:

Here is the caller graph for this function:

key ( )

Implementation of Iterator::key().

This is called when entering a loop iteration, returning the key of the current row. It must be a scalar - we will serialize to fulfill the requirement, but using getCurrentKey() is preferable.

lookupDestinationId ( array  $source_id_values)

{Looks up the destination identifier corresponding to a source key.Given a (possibly multi-field) source identifier value, return the (possibly multi-field) destination identifier value it is mapped to.

Parameters
array$source_id_valuesThe source identifier keyed values of the record, e.g. ['nid' => 5].
Returns
array The destination identifier values of the record, or NULL on failure.
}

Implements MigrateIdMapInterface.

References Sql\destinationIdFields(), Sql\getDatabase(), Sql\mapTableName(), and Sql\sourceIdFields().

Here is the call graph for this function:

lookupSourceID ( array  $destination_id_values)

{Looks up the source identifier.Given a (possibly multi-field) destination identifier value, return the (possibly multi-field) source identifier value mapped to it.

Parameters
array$destination_id_valuesThe destination identifier keyed values of the record, e.g. ['nid' => 5].
Returns
array The source identifier keyed values of the record, e.g. ['nid' => 5], or an empty array on failure.
}

Implements MigrateIdMapInterface.

References Sql\destinationIdFields(), Sql\getDatabase(), Sql\mapTableName(), and Sql\sourceIdFields().

Referenced by Sql\deleteDestination().

Here is the call graph for this function:

Here is the caller graph for this function:

mapTableName ( )

The name of the database map table.

Returns
string The map table name.

References Sql\init().

Referenced by Sql\countHelper(), Sql\delete(), Sql\deleteDestination(), Sql\destroy(), Sql\ensureTables(), Sql\getQualifiedMapTableName(), Sql\getRowByDestination(), Sql\getRowBySource(), Sql\getRowsNeedingUpdate(), Sql\importedCount(), Sql\init(), Sql\lookupDestinationId(), Sql\lookupSourceID(), Sql\prepareUpdate(), Sql\processedCount(), Sql\rewind(), Sql\saveIdMapping(), and Sql\setUpdate().

Here is the call graph for this function:

Here is the caller graph for this function:

messageCount ( )

{Returns the number of messages saved.

Returns
int The number of messages.
}

Implements MigrateIdMapInterface.

References Sql\countHelper(), and Sql\messageTableName().

Here is the call graph for this function:

messageTableName ( )

The name of the database message table.

Returns
string The message table name.

References Sql\init().

Referenced by Sql\clearMessages(), Sql\delete(), Sql\deleteDestination(), Sql\destroy(), Sql\ensureTables(), Sql\getMessageIterator(), Sql\init(), Sql\messageCount(), and Sql\saveMessage().

Here is the call graph for this function:

Here is the caller graph for this function:

next ( )

Implementation of Iterator::next().

This is called at the bottom of the loop implicitly, as well as explicitly from rewind().

References Sql\sourceIdFields().

Referenced by Sql\rewind().

Here is the call graph for this function:

Here is the caller graph for this function:

prepareUpdate ( )

{Prepares to run a full update.Prepares this migration to run as an update - that is, in addition to unmigrated content (source records not in the map table) being imported, previously-migrated content will also be updated in place by marking all previously-imported content as ready to be re-imported.}

Implements MigrateIdMapInterface.

References Sql\getDatabase(), and Sql\mapTableName().

Here is the call graph for this function:

processedCount ( )

{Returns the number of processed items in the map.

Returns
int The count of records in the map table.
}

Implements MigrateIdMapInterface.

References Sql\getDatabase(), and Sql\mapTableName().

Here is the call graph for this function:

rewind ( )

Implementation of Iterator::rewind().

This is called before beginning a foreach loop.

References Sql\destinationIdFields(), Sql\getDatabase(), Sql\mapTableName(), Sql\next(), and Sql\sourceIdFields().

Here is the call graph for this function:

saveIdMapping ( Row  $row,
array  $destination_id_values,
  $source_row_status = MigrateIdMapInterface::STATUS_IMPORTED,
  $rollback_action = MigrateIdMapInterface::ROLLBACK_DELETE 
)

{Saves a mapping from the source identifiers to the destination identifiers.Called upon import of one row, we record a mapping from the source ID to the destination ID. Also may be called, setting the third parameter to NEEDS_UPDATE, to signal an existing record should be re-migrated.

Parameters
\Drupal\migrate\Row$rowThe raw source data. We use the ID map derived from the source object to get the source identifier values.
array$destination_id_valuesAn array of destination identifier values.
int$status(optional) Status of the source row in the map. Defaults to self::STATUS_IMPORTED.
int$rollback_action(optional) How to handle the destination object on rollback. Defaults to self::ROLLBACK_DELETE.
}

Implements MigrateIdMapInterface.

References Sql\destinationIdFields(), Sql\getDatabase(), Row\getHash(), Row\getSourceIdValues(), Sql\mapTableName(), Sql\sourceIdFields(), and t().

Here is the call graph for this function:

saveMessage ( array  $source_id_values,
  $message,
  $level = MigrationInterface::MESSAGE_ERROR 
)

{Saves a message related to a source record in the migration message table.

Parameters
array$source_id_valuesThe source identifier keyed values of the record, e.g. ['nid' => 5].
string$messageThe message to record.
int$level(optional) The message severity. Defaults to MigrationInterface::MESSAGE_ERROR.
}

Implements MigrateIdMapInterface.

References Sql\getDatabase(), Sql\messageTableName(), and Sql\sourceIdFields().

Here is the call graph for this function:

setMessage ( MigrateMessageInterface  $message)

{Sets the migrate message.

Parameters
\Drupal\migrate\MigrateMessageInterface$messageThe message to display.
}

Implements MigrateIdMapInterface.

setUpdate ( array  $source_id_values)

{Sets a specified record to be updated, if it exists.

Parameters
array$source_id_valuesThe source identifier values of the record.
}

Implements MigrateIdMapInterface.

References Sql\getDatabase(), Sql\mapTableName(), and Sql\sourceIdFields().

Here is the call graph for this function:

sourceIdFields ( )
protected

The source ID fields.

Returns
array The source ID fields.

Referenced by Sql\delete(), Sql\deleteDestination(), Sql\getMessageIterator(), Sql\getRowBySource(), Sql\lookupDestinationId(), Sql\lookupSourceID(), Sql\next(), Sql\rewind(), Sql\saveIdMapping(), Sql\saveMessage(), and Sql\setUpdate().

Here is the caller graph for this function:

updateCount ( )

{Returns a count of items which are marked as needing update.

Returns
int The number of items which need updating.
}

Implements MigrateIdMapInterface.

References Sql\countHelper().

Here is the call graph for this function:

valid ( )

Implementation of Iterator::valid().

This is called at the top of the loop, returning TRUE to process the loop and FALSE to terminate it.

Referenced by Sql\currentDestination().

Here is the caller graph for this function:


The documentation for this class was generated from the following file: