From 612a14f241e333cc0928f87f2a3bb21e435bc2df Mon Sep 17 00:00:00 2001 From: Modesto Caballero Date: Wed, 16 Jul 2014 14:16:33 +0200 Subject: [PATCH] Added File entity support. --- .../migrate_default_content.migrate.base.inc | 2 +- .../migrate_default_content.migrate.file.inc | 39 +++++++++++++++++++ migrate_default_content.info | 1 + 3 files changed, 41 insertions(+), 1 deletion(-) create mode 100644 includes/migrate_default_content.migrate.file.inc diff --git a/includes/migrate_default_content.migrate.base.inc b/includes/migrate_default_content.migrate.base.inc index 23968dd..3e0e623 100644 --- a/includes/migrate_default_content.migrate.base.inc +++ b/includes/migrate_default_content.migrate.base.inc @@ -84,7 +84,7 @@ abstract class defaultBaseMigration extends Migration { } } - private function preprocessMapping($key, $value) { + protected function preprocessMapping($key, $value) { if (!is_array($value)) { return; } diff --git a/includes/migrate_default_content.migrate.file.inc b/includes/migrate_default_content.migrate.file.inc new file mode 100644 index 0000000..e24901f --- /dev/null +++ b/includes/migrate_default_content.migrate.file.inc @@ -0,0 +1,39 @@ +arguments = $arguments; + parent::__construct($arguments); + + $this->addDefaultMappings(); + + $this->map = new MigrateSQLMap($this->machineName, + array( + 'id' => array( + 'type' => 'varchar', + 'length' => 255, + 'not null' => TRUE, + ), + ), + MigrateDestinationFile::getKeySchema() + ); + // Create a MigrateSource object. + $this->source = $this->getMigrationSource(); + $this->destination = new MigrateDestinationFile($this->migrationData['bundle']); + + } + + protected function preprocessMapping($key, $value) { + if ($key == 'source_dir') { + $value['default_value'] = $this->arguments['source_path'] . '/' . $value['default_value']; + } + parent::preprocessMapping($key, $value); + } + + +} diff --git a/migrate_default_content.info b/migrate_default_content.info index dea8ada..307efef 100644 --- a/migrate_default_content.info +++ b/migrate_default_content.info @@ -9,6 +9,7 @@ dependencies[] = libraries files[] = 'includes/migrate_default_content.migrate.base.inc' files[] = 'includes/migrate_default_content.migrate.entity.inc' +files[] = 'includes/migrate_default_content.migrate.file.inc' files[] = 'includes/migrate_default_content.migrate.field_collection.inc' files[] = 'includes/migrate_default_content.migrate.menu.inc' files[] = 'includes/migrate_default_content.migrate.user.inc'