summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt2
-rw-r--r--plugins/destinations/comment.inc22
-rw-r--r--plugins/destinations/entity.inc7
-rw-r--r--plugins/destinations/node.inc32
-rw-r--r--plugins/destinations/term.inc19
-rw-r--r--plugins/destinations/user.inc19
-rw-r--r--plugins/sources/mssql.inc14
-rw-r--r--plugins/sources/sql.inc22
8 files changed, 104 insertions, 33 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 5b9eeda..c9672f6 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -11,7 +11,7 @@ Features and enhancements
machine name rather than class name.
MigrationBase::getInstance now takes a machine name rather than a class name.
Migration class names are no longer required to end in 'Migration'.
-
+- #992898 - Pass options to source and destination constructors as arrays.
Add logging of fetch queries and dqp() function to translate DBTNG query object into full SQL.
Inherit default settings for promote, sticky, status, status from content type
configuration. Already done in D7.
diff --git a/plugins/destinations/comment.inc b/plugins/destinations/comment.inc
index 37892cf..4419875 100644
--- a/plugins/destinations/comment.inc
+++ b/plugins/destinations/comment.inc
@@ -25,17 +25,27 @@ class MigrateDestinationComment extends MigrateDestinationEntity {
}
/**
+ * Return an options array for comment destinations.
+ *
+ * @param string $language
+ * Default language for comments created via this destination class.
+ * @param string $text_format
+ * Default text format for comments created via this destination class.
+ */
+ static public function options($language, $text_format) {
+ return compact('language', 'text_format');
+ }
+
+ /**
* Basic initialization
*
* @param string $bundle
* A.k.a. the content type (page, article, etc.) of the ... comment?.
- * @param string $language
- * Language of the node content.
- * @param string $text_format
- * Default text format for fields on this comment. Can be overridden.
+ * @param array $options
+ * Options applied to comments.
*/
- public function __construct($bundle, $language = NULL, $text_format = NULL) {
- parent::__construct('comment', $bundle, $language, $text_format);
+ public function __construct($bundle, array $options = array()) {
+ parent::__construct('comment', $bundle, $options);
}
/**
diff --git a/plugins/destinations/entity.inc b/plugins/destinations/entity.inc
index 3d4d0e1..434f720 100644
--- a/plugins/destinations/entity.inc
+++ b/plugins/destinations/entity.inc
@@ -58,13 +58,12 @@ abstract class MigrateDestinationEntity extends MigrateDestination {
*
* @param array $key_schema
*/
- public function __construct($entity_type, $bundle,
- $language = NULL, $text_format = NULL) {
+ public function __construct($entity_type, $bundle, array $options = array()) {
parent::__construct();
$this->entityType = $entity_type;
$this->bundle = $bundle;
- $this->language = isset($language) ? $language : LANGUAGE_NONE;
- $this->textFormat = isset($text_format) ? $text_format : filter_fallback_format();
+ $this->language = isset($options['language']) ? $options['language'] : LANGUAGE_NONE;
+ $this->textFormat = isset($options['text_format']) ? $options['text_format'] : filter_fallback_format();
}
public function __toString() {
diff --git a/plugins/destinations/node.inc b/plugins/destinations/node.inc
index 298ec42..8c9cd20 100644
--- a/plugins/destinations/node.inc
+++ b/plugins/destinations/node.inc
@@ -25,15 +25,27 @@ class MigrateDestinationNode extends MigrateDestinationEntity {
}
/**
+ * Return an options array for node destinations.
+ *
+ * @param string $language
+ * Default language for nodes created via this destination class.
+ * @param string $text_format
+ * Default text format for nodes created via this destination class.
+ */
+ static public function options($language, $text_format) {
+ return compact('language', 'text_format');
+ }
+
+ /**
* Basic initialization
*
* @param string $bundle
* A.k.a. the content type (page, article, etc.) of the node.
- * @param string $language
- * Default language for nodes created via this destination class.
+ * @param array $options
+ * Options applied to nodes.
*/
- public function __construct($bundle, $language = NULL, $text_format = NULL) {
- parent::__construct('node', $bundle, $language, $text_format);
+ public function __construct($bundle, array $options = array()) {
+ parent::__construct('node', $bundle, $options);
}
/**
@@ -144,7 +156,7 @@ class MigrateDestinationNode extends MigrateDestinationEntity {
$type_info = node_get_types('type', $node->type);
if (empty($node->nid)) {
// Avoids notice in forum module and maybe more - http://drupal.org/node/839770 is similar.
- $node->nid = NULL;
+ $node->nid = NULL;
}
// Save changed timestamp and set it later, node_save sets it unconditionally
@@ -155,12 +167,12 @@ class MigrateDestinationNode extends MigrateDestinationEntity {
if (isset($node->created)) {
$node->created = MigrationBase::timestamp($node->created);
}
-
+
// Generate teaser from Body if teaser not specified and Body is in use.
if ($type_info->has_body && empty($node->teaser) && !empty($node->body)) {
$node->teaser = node_teaser($node->body);
}
-
+
// Set defaults as per content type settings. Can't call node_object_prepare()
// since that clobbers existing values.
$node_options = variable_get('node_options_'. $node->type, array('status', 'promote'));
@@ -183,7 +195,7 @@ class MigrateDestinationNode extends MigrateDestinationEntity {
migrate_instrument_stop('node_save');
if (isset($node->nid)) {
-
+
// Unfortunately, http://drupal.org/node/722688 was not accepted, so fix
// the changed timestamp
if (isset($changed)) {
@@ -193,7 +205,7 @@ class MigrateDestinationNode extends MigrateDestinationEntity {
->execute();
$node->changed = $changed;
}
-
+
// Potentially fix uid and timestamp in node_revisions.
$query = db_update('node_revisions')
->condition('vid', $node->vid);
@@ -210,7 +222,7 @@ class MigrateDestinationNode extends MigrateDestinationEntity {
$query->execute();
}
}
-
+
$this->complete($node, $row);
// Clear the node cache periodically
diff --git a/plugins/destinations/term.inc b/plugins/destinations/term.inc
index 3892ed9..3bbc375 100644
--- a/plugins/destinations/term.inc
+++ b/plugins/destinations/term.inc
@@ -26,10 +26,25 @@ class MigrateDestinationTerm extends MigrateDestinationEntity {
}
/**
+ * Return an options array for term destinations.
+ *
+ * @param string $language
+ * Default language for terms created via this destination class.
+ * @param string $text_format
+ * Default text format for terms created via this destination class.
+ */
+ static public function options($language, $text_format) {
+ return compact('language', 'text_format');
+ }
+
+ /**
* Basic initialization
+ *
+ * @param array $options
+ * Options applied to terms.
*/
- public function __construct($bundle, $language = NULL, $text_format = NULL) {
- parent::__construct('taxonomy_term', $bundle, $language, $text_format);
+ public function __construct($bundle, array $options = array()) {
+ parent::__construct('taxonomy_term', $bundle, $options);
}
/**
diff --git a/plugins/destinations/user.inc b/plugins/destinations/user.inc
index 93ce1c2..8caccbe 100644
--- a/plugins/destinations/user.inc
+++ b/plugins/destinations/user.inc
@@ -26,10 +26,25 @@ class MigrateDestinationUser extends MigrateDestinationEntity {
}
/**
+ * Return an options array for user destinations.
+ *
+ * @param string $language
+ * Default language for usrs created via this destination class.
+ * @param string $text_format
+ * Default text format for users created via this destination class.
+ */
+ static public function options($language, $text_format) {
+ return compact('language', 'text_format');
+ }
+
+ /**
* Basic initialization
+ *
+ * @param array $options
+ * Options applied to comments.
*/
- public function __construct($language = NULL, $text_format = NULL) {
- parent::__construct('user', 'user', $language, $text_format);
+ public function __construct(array $options = array()) {
+ parent::__construct('user', 'user', $options);
}
/**
diff --git a/plugins/sources/mssql.inc b/plugins/sources/mssql.inc
index 0066c62..193f5dd 100644
--- a/plugins/sources/mssql.inc
+++ b/plugins/sources/mssql.inc
@@ -71,16 +71,26 @@ class MigrateSourceMSSQL extends MigrateSource {
protected $mapJoinable = FALSE;
/**
+ * Return an options array for MS SQL sourcews.
+ *
+ * @param int $batch_size
+ * Number of rows to pull at once (defaults to 500).
+ */
+ static public function options($batch_size) {
+ return compact('batch_size');
+ }
+
+ /**
* Simple initialization.
*/
public function __construct(array $configuration, $query, $count_query,
- array $fields, $batch_size = 500) {
+ array $fields, array $options = array()) {
parent::__construct();
$this->query = $query;
$this->countQuery = $count_query;
$this->configuration = $configuration;
$this->fields = $fields;
- $this->batchSize = $batch_size;
+ $this->batchSize = isset($options['batch_size']) ? $options['batch_size'] : 500;
}
/**
diff --git a/plugins/sources/sql.inc b/plugins/sources/sql.inc
index e8f0e05..e7380b9 100644
--- a/plugins/sources/sql.inc
+++ b/plugins/sources/sql.inc
@@ -62,6 +62,16 @@ class MigrateSourceSQL extends MigrateSource {
protected $usingHighwater = FALSE;
/**
+ * Return an options array for PDO sources.
+ *
+ * @param boolean $map_joinable
+ * Indicates whether the map table can be joined directly to the source query.
+ */
+ static public function options($map_joinable) {
+ return compact('map_joinable');
+ }
+
+ /**
* Simple initialization.
*
* @param SelectQuery $query
@@ -73,11 +83,11 @@ class MigrateSourceSQL extends MigrateSource {
* @param SelectQuery $count_query
* Optional - an explicit count query, primarily used when counting the
* primary query is slow.
- * @param boolean $map_joinable
- * Indicates whether the map table can be joined directly to the source query.
+ * @param boolean $options
+ * Options applied to this source.
*/
- public function __construct(SelectQuery $query,
- array $fields = array(), SelectQuery $count_query = NULL, $map_joinable = NULL) {
+ public function __construct(SelectQuery $query, array $fields = array(),
+ SelectQuery $count_query = NULL, array $options = array()) {
parent::__construct();
$this->originalQuery = $query;
$this->query = clone $query;
@@ -89,8 +99,8 @@ class MigrateSourceSQL extends MigrateSource {
$this->countQuery = $count_query;
}
- if (!is_null($map_joinable)) {
- $this->mapJoinable = $map_joinable;
+ if (isset($options['map_joinable'])) {
+ $this->mapJoinable = $options['map_joinable'];
}
else {
// TODO: We want to automatically determine if the map table can be joined