summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Ryan2010-12-22 03:16:06 (GMT)
committer Mike Ryan2010-12-22 03:16:06 (GMT)
commit386e47e4b36f7e3456f6549eab98ac6653c8da75 (patch)
treede5c1331d8b4265197a93e56a5aee9093814fc8c
parenta8d776ff02e0f95e1af2ecae0d4347bc8713d333 (diff)
#992898 by mikeryan: Pass options to source and destination constructors as arrays
-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.inc20
-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, 98 insertions, 27 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index f0de944..3e87c4d 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -12,7 +12,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.
Allow migration of comment enable/disable.
Check max_execution_time as well as memory_limit, for graceful exit when
max_execution_time is in play.
diff --git a/plugins/destinations/comment.inc b/plugins/destinations/comment.inc
index 397a8e9..22df162 100644
--- a/plugins/destinations/comment.inc
+++ b/plugins/destinations/comment.inc
@@ -31,17 +31,27 @@ class MigrateDestinationComment extends MigrateDestinationEntity {
protected $maintainNodeStatistics;
/**
+ * 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 c754050..d6ddbf7 100644
--- a/plugins/destinations/entity.inc
+++ b/plugins/destinations/entity.inc
@@ -56,13 +56,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 ef25d82..abb6f7e 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);
}
/**
diff --git a/plugins/destinations/term.inc b/plugins/destinations/term.inc
index 7db7f28..9fc239f 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 9b11a57..ae794e2 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 f2d58cd..a72409e 100644
--- a/plugins/sources/mssql.inc
+++ b/plugins/sources/mssql.inc
@@ -60,16 +60,26 @@ class MigrateSourceMSSQL extends MigrateSource {
protected $batchSize;
/**
+ * Return an options array for MS SQL sources.
+ *
+ * @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 7a725a1..173c26e 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