Commit dbc897f7 authored by mikeryan's avatar mikeryan Committed by greggles

Issue #1717496 by mikeryan: Migrate module support

parent 43f3d38a
......@@ -6,6 +6,7 @@ core = 7.x
configure = admin/config/people/comment_notify
files[] = comment_notify.install
files[] = comment_notify.module
files[] = comment_notify.migrate.inc
files[] = comment_notify.tokens.inc
files[] = comment_notify.inc
files[] = comment_notify.test
<?php
/**
* @file
* Migration support for the Comment Notify module.
*/
/**
* Field handler.
*/
class CommentNotifyMigrationHandler extends MigrateDestinationHandler {
public function __construct() {
$this->registerTypes(array('comment'));
}
/**
* Make the destination field visible.
*/
public function fields() {
return array(
'notify' => t('Comment Notify: Whether to send notifications for this comment'),
'notified' => t('Comment Notify: Whether notifications have been sent for this comment'),
'notify_hash' => t('Comment Notify: Hash representing this notification'),
);
}
/**
* Implements MigrateDestinationHandler::prepare().
*
* @param $comment
* The comment object being prepared for saving.
* @param $row
* Raw source data for the migration - ignored.
*/
public function prepare($comment, $row) {
// By default, set notifications off
if (!isset($comment->notify)) {
$comment->notify = 0;
}
if (!isset($comment->notify_type)) {
$comment->notify_type = 1;
}
}
/**
* Implements MigrateDestinationHandler::complete().
*
* @param $comment
* The comment object taht was just saved.
* @param $row
* Raw source data for the migration - ignored.
*/
public function complete($comment, $row) {
if (!isset($comment->notified) || $comment->notified) {
comment_notify_mark_comment_as_notified($comment);
}
}
}
/*
* Implementats hook_migrate_api().
*/
function comment_notify_migrate_api() {
$api = array(
'api' => 2,
);
return $api;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment