class CommentNotifyMigrationHandler in Comment Notify 8
Same name and namespace in other branches
- 7 comment_notify.migrate.inc \CommentNotifyMigrationHandler
Field handler.
Hierarchy
- class \CommentNotifyMigrationHandler extends \MigrateDestinationHandler
Expanded class hierarchy of CommentNotifyMigrationHandler
File
- ./
comment_notify.migrate.inc, line 11 - Migration support for the Comment Notify module.
View source
class CommentNotifyMigrationHandler extends MigrateDestinationHandler {
/**
* {@inheritdoc}
*/
public function __construct() {
$this
->registerTypes([
'comment',
]);
}
/**
* Make the destination field visible.
*/
public function fields() {
return [
'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);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CommentNotifyMigrationHandler:: |
public | function | Implements MigrateDestinationHandler::complete(). | |
CommentNotifyMigrationHandler:: |
public | function | Make the destination field visible. | |
CommentNotifyMigrationHandler:: |
public | function | Implements MigrateDestinationHandler::prepare(). | |
CommentNotifyMigrationHandler:: |
public | function |