public function DrupalPicture6Migration::__construct in Drupal-to-Drupal data migration 7.2
Required arguments:
source_connection - Connection key for the DatabaseConnection holding the source Drupal installation. source_version - Major version number (as an integer) of the source install. machine_name - Machine name under which a particular migration is registered. description - Description of the migration. group_name - The group (import job) containing this migration (import task).
Optional arguments:
source_database - Array describing the source connection, to be defined in the constructor. If absent, the source connection is assumed to be established elsewhere (typically settings.php). group - Migration group to add this migration to. dependencies - Array of migrations that must be run before this one. soft_dependencies - Array of migrations that should be listed before this one. format_mappings - Array keyed by source format IDs or machine names, with the values being the corresponding D7 machine name. If unspecified, source_options - Array to be passed as options to source constructors, overriding the defaults (map_joinable FALSE, cache_counts TRUE, cache_key derived from the machine name). version_class - The name of a custom DrupalVersion class overriding the default derived from source_version. new_only - For any destination types that support highwater marks or track_changes, suppress that support so repeated migrations only import new items.
Parameters
array $arguments:
Overrides DrupalFile6Migration::__construct
File
- d6/
file.inc, line 100 - Implementation of DrupalFileMigration for Drupal 6 sources.
Class
- DrupalPicture6Migration
- Pull user pictures in their own migration class, based on normal file migration.
Code
public function __construct(array $arguments) {
// Drupal 6 pictures are filespecs, so we override the map to use the paths
// as the source key. Must do this before calling the parent constructor,
// which will default it to an integer key.
$this->map = new MigrateSQLMap($arguments['machine_name'], array(
'picture' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'Source filespec',
),
), MigrateDestinationFile::getKeySchema());
parent::__construct($arguments);
if (!$this->newOnly) {
// Override the highwater definition, the best timestamp we have in this
// case is users.access.
$this->highwaterField = array(
'name' => 'access',
'alias' => 'f',
'type' => 'int',
);
}
// Override these mappings to use 'picture' instead of 'filepath'.
$this
->addFieldMapping('value', 'picture', FALSE);
$this
->addFieldMapping('destination_file', 'picture', FALSE)
->callbacks(array(
$this,
'fixUri',
));
// No appropriate timestamp to save, so let it default.
$this
->addFieldMapping('timestamp', NULL, FALSE);
// Not mapped directly, just used for highwater
$this
->addUnmigratedSources(array(
'access',
));
// Clear references to normal file source fields
$this
->removeFieldMapping(NULL, 'filename');
$this
->removeFieldMapping(NULL, 'filemime');
$this
->removeFieldMapping(NULL, 'filesize');
$this
->removeFieldMapping(NULL, 'status');
$this
->removeFieldMapping(NULL, 'type');
}