From 33354ffbe470ea09b7139978c5ae79ff07c79b85 Mon Sep 17 00:00:00 2001 From: rvilar Date: Thu, 17 Dec 2015 18:49:18 +0100 Subject: [PATCH] Added feature to specify csv options in config files. --- includes/migrate_default_content.migrate.base.inc | 8 +++++++- includes/migrate_default_content.migrate.menu.inc | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/includes/migrate_default_content.migrate.base.inc b/includes/migrate_default_content.migrate.base.inc index 02d340f..5003453 100644 --- a/includes/migrate_default_content.migrate.base.inc +++ b/includes/migrate_default_content.migrate.base.inc @@ -68,7 +68,13 @@ abstract class defaultBaseMigration extends Migration { // Rebuild the csv columns array. $this->csvColumns = array_merge($csv_cols, $this->csvColumns); - return new MigrateSourceCSV($this->arguments['source_path'] . '/' . $this->arguments['source_file'], $this->csvColumns, array('header_rows' => 1)); + // Merge default options with other specified in config files. + $options = array('header_rows' => 1); + if ($this->migrationData['options']) { + $options = array_merge($options, $this->migrationData['options'][0]); + } + return new MigrateSourceCSV($this->arguments['source_path'] . '/' . $this->arguments['source_file'], $this->csvColumns, $options); + } protected function addDefaultMappings() { diff --git a/includes/migrate_default_content.migrate.menu.inc b/includes/migrate_default_content.migrate.menu.inc index 3991728..cfd311d 100644 --- a/includes/migrate_default_content.migrate.menu.inc +++ b/includes/migrate_default_content.migrate.menu.inc @@ -48,11 +48,16 @@ class defaultMenu extends defaultBaseMigration { /** * Implements MigrateDestination::prepare(). - * Adds default weight for menu item if there isn't any. + * Adds default weight for menu item if there isn't any and decode JSON + * options. */ public function prepareRow($row) { if (empty($row->weight)) { $row->weight = 0; } + if (!empty($row->options)) { + $options = drupal_json_decode($row->options); + $row->options = $options; + } } }