public function WordPressComment::__construct in WordPress Migrate 7
Same name and namespace in other branches
- 7.2 wordpress_comment.inc \WordPressComment::__construct()
Set it up
Overrides WordPressMigration::__construct
File
- ./
wordpress_comment.inc, line 73 - Support for migrating comments from a WordPress blog into Drupal.
Class
- WordPressComment
- Implementation of WordPressMigration, for comments
Code
public function __construct(array $arguments = array()) {
$arguments['post_type'] = 'comment_node_' . variable_get('wordpress_migrate_post_type', 'blog');
parent::__construct($arguments);
$this->dependencies = array(
$this
->generateMachineName('WordPressBlogEntry'),
);
$this->softDependencies = array(
$this
->generateMachineName('WordPressPage'),
);
// comment_id is the unique ID of items in WordPress
$this->map = new MigrateSQLMap($this->machineName, array(
'comment_id' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'description' => 'WordPress comment ID',
),
), MigrateDestinationComment::getKeySchema());
$this->source = new WordPressCommentSource($this->wxrFile);
$this->destination = new MigrateDestinationComment($arguments['post_type']);
// The basic mappings
$this
->addFieldMapping('nid', 'post_id')
->sourceMigration(array(
$this
->generateMachineName('WordPressBlogEntry'),
$this
->generateMachineName('WordPressPage'),
));
$this
->addFieldMapping('pid', 'comment_parent')
->sourceMigration($this
->generateMachineName('WordPressComment'));
$this
->addFieldMapping('uid')
->description('Use email to match Drupal account; if no match, default to anonymous');
$this
->addFieldMapping('subject')
->description('No comment subjects in WP')
->issueGroup('DNM');
$this
->addFieldMapping('hostname', 'comment_author_IP');
$this
->addFieldMapping('created', 'comment_date');
$this
->addFieldMapping('changed', 'comment_date');
$this
->addFieldMapping(NULL, 'comment_date_gmt')
->description('Using comment_date')
->issueGroup('DNM');
$this
->addFieldMapping('status', 'comment_approved')
->description('Do not import those with values of "spam"');
$this
->addFieldMapping('thread')
->issueGroup('DNM');
$this
->addFieldMapping('name', 'comment_author');
$this
->addFieldMapping('mail', 'comment_author_email');
$this
->addFieldMapping('homepage', 'comment_author_url');
$this
->addFieldMapping('language');
$this
->addFieldMapping('path');
$this
->addFieldMapping(NULL, 'comment_id')
->description('Source primary key')
->issueGroup('DNM');
$this
->addFieldMapping(NULL, 'comment_user_id')
->description('Always 0?')
->issueGroup('DNM');
$this
->addFieldMapping(NULL, 'comment_type')
->description('Always empty?')
->issueGroup('DNM');
$text_format = variable_get('wordpress_migrate_text_format', 'filtered_html');
$arguments = array(
'format' => $text_format,
);
$this
->addFieldMapping('comment_body', 'comment_content')
->arguments($arguments);
}