Issue #2862671 by masipila, Jo Fitzgerald, kleog, phenaproxima, quietone: Add documentation to SqlBase source plugin
parent
be64202643
commit
4851f311e2
|
@ -17,35 +17,48 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||||
/**
|
/**
|
||||||
* Sources whose data may be fetched via a database connection.
|
* Sources whose data may be fetched via a database connection.
|
||||||
*
|
*
|
||||||
* Database configuration, which may appear either within the source plugin
|
* Available configuration keys:
|
||||||
* configuration or in state, is structured as follows:
|
* - database_state_key: (optional) Name of the state key which contains an
|
||||||
|
* array with database connection information.
|
||||||
|
* - key: (optional) The database key name. Defaults to 'migrate'.
|
||||||
|
* - target: (optional) The database target name. Defaults to 'default'.
|
||||||
|
* - batch_size: (optional) Number of records to fetch from the database during
|
||||||
|
* each batch. If omitted, all records are fetched in a single query.
|
||||||
|
* - ignore_map: (optional) Source data is joined to the map table by default.
|
||||||
|
* If set to TRUE, the map table will not be joined.
|
||||||
*
|
*
|
||||||
* 'key' - The database key name (defaults to 'migrate').
|
* For other optional configuration keys inherited from the parent class, refer
|
||||||
* 'target' - The database target name (defaults to 'default').
|
* to \Drupal\migrate\Plugin\migrate\source\SourcePluginBase.
|
||||||
* 'database' - Database connection information as accepted by
|
|
||||||
* Database::addConnectionInfo(). If not present, the key/target is assumed
|
|
||||||
* to already be defined (e.g., in settings.php).
|
|
||||||
*
|
*
|
||||||
* This configuration info is obtained in the following order:
|
* About the source database determination:
|
||||||
*
|
* - If the source plugin configuration contains 'database_state_key', its value
|
||||||
* 1. If the source plugin configuration contains a key 'database_state_key',
|
* is taken as the name of a state key which contains an array with the
|
||||||
* its value is taken as the name of a state key which contains an array
|
|
||||||
* with the above database configuration.
|
|
||||||
* 2. Otherwise, if the source plugin configuration contains 'key', the above
|
|
||||||
* database configuration is obtained directly from the plugin configuration.
|
|
||||||
* 3. Otherwise, if the state 'migrate.fallback_state_key' exists, its value is
|
|
||||||
* taken as the name of a state key which contains an array with the above
|
|
||||||
* database configuration.
|
* database configuration.
|
||||||
* 4. Otherwise, if a connection named 'migrate' exists, that is used as the
|
* - Otherwise, if the source plugin configuration contains 'key', the database
|
||||||
* database connection.
|
* configuration with that name is used.
|
||||||
* 5. Otherwise, RequirementsException is thrown.
|
* - If both 'database_state_key' and 'key' are omitted in the source plugin
|
||||||
|
* configuration, the database connection named 'migrate' is used by default.
|
||||||
|
* - If all of the above steps fail, RequirementsException is thrown.
|
||||||
*
|
*
|
||||||
* It is strongly recommended that database connections be explicitly defined
|
* Drupal Database API supports multiple database connections. The connection
|
||||||
* via 'database_state_key' or in the source plugin configuration. Defining
|
* parameters are defined in $databases array in settings.php or
|
||||||
* migrate.fallback_state_key or a 'migrate' connection affects not only any
|
* settings.local.php. It is also possible to modify the $databases array in
|
||||||
* migrations intended to use that particular connection, but all
|
* runtime. For example, Migrate Drupal, which provides the migrations from
|
||||||
* SqlBase-derived source plugins which do not have explicit database
|
* Drupal 6 / 7, asks for the source database connection parameters in the UI
|
||||||
* configuration.
|
* and then adds the $databases['migrate'] connection in runtime before the
|
||||||
|
* migrations are executed.
|
||||||
|
*
|
||||||
|
* As described above, the default source database is $databases['migrate']. If
|
||||||
|
* the source plugin needs another source connection, the database connection
|
||||||
|
* parameters should be added to the $databases array as, for instance,
|
||||||
|
* $databases['foo']. The source plugin can then use this connection by setting
|
||||||
|
* 'key' to 'foo' in its configuration.
|
||||||
|
*
|
||||||
|
* For a complete example on migrating data from an SQL source, refer to
|
||||||
|
* https://www.drupal.org/docs/8/api/migrate-api/migrating-data-from-sql-source
|
||||||
|
*
|
||||||
|
* @see https://www.drupal.org/docs/8/api/database-api
|
||||||
|
* @see \Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase
|
||||||
*/
|
*/
|
||||||
abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPluginInterface, RequirementsInterface {
|
abstract class SqlBase extends SourcePluginBase implements ContainerFactoryPluginInterface, RequirementsInterface {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue