public function WineFileCopyMigration::__construct in Migrate 7.2
General initialization of a Migration object.
Overrides AdvancedExampleMigration::__construct
File
- migrate_example/
wine.inc, line 190 - Advanced migration examples. These serve two purposes:
Class
- WineFileCopyMigration
- TIP: Files can be migrated directly by themselves, by using the MigrateDestinationFile class. This will copy the files themselves from the source, and set up the Drupal file tables appropriately. Referencing them in, say, a node field later is then…
Code
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Profile images');
$query = db_select('migrate_example_wine_files', 'wf')
->fields('wf', array(
'imageid',
'url',
))
->isNull('wineid');
$this->source = new MigrateSourceSQL($query);
$this->destination = new MigrateDestinationFile();
$this->map = new MigrateSQLMap($this->machineName, array(
'imageid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Image ID.',
),
), MigrateDestinationFile::getKeySchema());
// In the simplest case, just map the incoming URL to 'value'.
$this
->addFieldMapping('value', 'url');
$this
->addUnmigratedDestinations(array(
'destination_dir',
'destination_file',
'fid',
'file_replace',
'preserve_files',
'source_dir',
'timestamp',
'uid',
'urlencode',
));
$this
->removeFieldMapping('pathauto');
}