Skip to content

Instantly share code, notes, and snippets.

@alex-moreno
Last active March 1, 2018 16:26
Show Gist options
  • Save alex-moreno/30be9b0029bb38020594a3151417e4dd to your computer and use it in GitHub Desktop.
Save alex-moreno/30be9b0029bb38020594a3151417e4dd to your computer and use it in GitHub Desktop.
<pre><code class="language-php">
<php
$this->addFieldMapping('field_blob_attachment', 'attachmentid')
->sourceMigration('FileBlob');
$this->addFieldMapping('field_blob_attachment:file_class')
->defaultValue('MigrateFileFid');
?>
</code></pre>
<pre><code class="language-php">
<?php
class FileBlobMigration extends Migration {
public function __construct() {
$query = db_select('legacy_file_data', 'f')
->fields('f', array('attachmentid', 'attachmentblob', 'filename', 'file_ownerid'));
$this->source = new MigrateSourceSQL($query);
$this->destination = new MigrateDestinationFile('file', 'MigrateFileBlob');
$this->addFieldMapping('value', 'attachmentblob');
$this->addFieldMapping('destination_file', 'filename');
$this->addFieldMapping('uid', 'file_ownerid')
->sourceMigration('User');
?>
</code></pre>
<pre><code class="language-php">
<?php
$this-addFieldMapping('field_image', 'image_filename');
$this->addFieldMapping('field_image:source_dir')
->defaultValue('/mnt/files');
$this->addFieldMapping('field_image:alt', 'image_alt');
$this->addFieldMapping('field_image:title', 'image_title');
?>
</code></pre>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment