Created
September 27, 2018 17:31
-
-
Save neclimdul/f16220aac76e25beba8e0fe97c12b40f to your computer and use it in GitHub Desktop.
d6_node_flag
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
id: d6_flags | |
label: D6 Flag Migration | |
source: | |
plugin: d6_flag_bookmarks | |
constants: | |
dest_type: node | |
flag_id: resource_content_flag | |
global: 0 | |
process: | |
id: fcid | |
flag_id: 'constants/flag_id' | |
entity_type: 'constants/dest_type' | |
global: 'constants/global' | |
entity_id: | |
plugin: migration_lookup | |
migration: d6_node | |
source: content_id | |
uid: | |
plugin: migration_lookup | |
migration: d6_user | |
source: uid | |
destination: | |
plugin: entity:flagging | |
migration_dependencies: | |
required: | |
- d6_user | |
- d6_node |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Drupal\my_migration\Plugin\migrate\source; | |
use Drupal\migrate\Plugin\migrate\source\SqlBase; | |
/** | |
* Migrate flags from d6 -> d8. | |
* | |
* @MigrateSource( | |
* id = "d6_flag_bookmarks", | |
* source_module = "flag" | |
* ) | |
*/ | |
class D6FlagBookmarks extends SqlBase { | |
/** | |
* {@inheritdoc} | |
*/ | |
public function fields() { | |
return [ | |
'fcid' => $this->t('Flag id id'), | |
'content_id' => $this->t('Content(node) id'), | |
'uid' => $this->t('Flagging user'), | |
'timestamp' => $this->t('timestamp of the flag'), | |
]; | |
} | |
/** | |
* {@inheritdoc} | |
*/ | |
public function getIds() { | |
return [ | |
'fcid' => [ | |
'type' => 'integer', | |
], | |
]; | |
} | |
/** | |
* @return \Drupal\Core\Database\Query\SelectInterface | |
*/ | |
public function query() { | |
$query = $this->select('flag_content', 'f'); | |
$query->fields('f', [ | |
'fcid', | |
'content_id', | |
'uid', | |
'timestamp' | |
]); | |
$query->orderBy('fcid', 'asc'); | |
$query->join('node', 'n', 'n.nid = f.content_id'); | |
if ($this->configuration['content_type']) { | |
$query->where('n.type = :content_type', [ | |
'content_type' => $this->configuration['content_type'], | |
]); | |
} | |
return $query; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment