summaryrefslogtreecommitdiffstats
path: root/core/modules/node/src/Plugin/migrate/source/d6/Node.php
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/node/src/Plugin/migrate/source/d6/Node.php')
-rw-r--r--core/modules/node/src/Plugin/migrate/source/d6/Node.php35
1 files changed, 30 insertions, 5 deletions
diff --git a/core/modules/node/src/Plugin/migrate/source/d6/Node.php b/core/modules/node/src/Plugin/migrate/source/d6/Node.php
index 1ed96f9..5ca698f 100644
--- a/core/modules/node/src/Plugin/migrate/source/d6/Node.php
+++ b/core/modules/node/src/Plugin/migrate/source/d6/Node.php
@@ -2,6 +2,7 @@
namespace Drupal\node\Plugin\migrate\source\d6;
+use Drupal\Core\Database\Query\SelectInterface;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
@@ -37,9 +38,11 @@ class Node extends DrupalSqlBase {
* {@inheritdoc}
*/
public function query() {
- // Select node in its last revision.
- $query = $this->select('node_revisions', 'nr')
- ->fields('n', array(
+ $query = $this->select('node_revisions', 'nr');
+ $query->innerJoin('node', 'n', static::JOIN);
+ $this->handleTranslations($query);
+
+ $query->fields('n', array(
'nid',
'type',
'language',
@@ -54,17 +57,16 @@ class Node extends DrupalSqlBase {
'translate',
))
->fields('nr', array(
- 'vid',
'title',
'body',
'teaser',
'log',
'timestamp',
'format',
+ 'vid',
));
$query->addField('n', 'uid', 'node_uid');
$query->addField('nr', 'uid', 'revision_uid');
- $query->innerJoin('node', 'n', static::JOIN);
if (isset($this->configuration['node_type'])) {
$query->condition('n.type', $this->configuration['node_type']);
@@ -123,6 +125,11 @@ class Node extends DrupalSqlBase {
}
}
+ // Make sure we always have a translation set.
+ if ($row->getSourceProperty('tnid') == 0) {
+ $row->setSourceProperty('tnid', $row->getSourceProperty('nid'));
+ }
+
return parent::prepareRow($row);
}
@@ -251,4 +258,22 @@ class Node extends DrupalSqlBase {
return $ids;
}
+ /**
+ * Adapt our query for translations.
+ *
+ * @param \Drupal\Core\Database\Query\SelectInterface
+ * The generated query.
+ */
+ protected function handleTranslations(SelectInterface $query) {
+ // Check whether or not we want translations.
+ if (empty($this->configuration['translations'])) {
+ // No translations: Yield untranslated nodes, or default translations.
+ $query->where('n.tnid = 0 OR n.tnid = n.nid');
+ }
+ else {
+ // Translations: Yield only non-default translations.
+ $query->where('n.tnid <> 0 AND n.tnid <> n.nid');
+ }
+ }
+
}