public function WineFileBlobMigration::__construct in Migrate 7.2
General initialization of a Migration object.
Overrides AdvancedExampleMigration::__construct
File
- migrate_example/
wine.inc, line 237 - Advanced migration examples. These serve two purposes:
Class
- WineFileBlobMigration
- Migration class to test importing from a BLOB column into a file entity.
Code
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Example migration from BLOB column into files.');
$query = db_select('migrate_example_wine_blobs', 'wf')
->fields('wf', array(
'imageid',
'imageblob',
));
$this->source = new MigrateSourceSQL($query);
// Note that the WineFileCopyMigration example let the second argument,
// the file_class, default to MigrateFileUri, indicating that the
// 'value' we're passing was a URI. In this case, we're passing a blob, so
// tell the destination to expect it.
$this->destination = new MigrateDestinationFile('file', 'MigrateFileBlob');
$this->map = new MigrateSQLMap($this->machineName, array(
'imageid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'Image ID.',
),
), MigrateDestinationFile::getKeySchema());
// Basic fields
$this
->addFieldMapping('value', 'imageblob')
->description('An image blob in the DB');
// The destination filename must be specified for blobs
$this
->addFieldMapping('destination_file')
->defaultValue('druplicon.png');
$this
->addFieldMapping('uid')
->defaultValue(1);
// Unmapped destination fields
$this
->addUnmigratedDestinations(array(
'destination_dir',
'fid',
'file_replace',
'preserve_files',
'timestamp',
));
$this
->removeFieldMapping('pathauto');
}