Projet

Général

Profil

Paste
Télécharger (1,57 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / comment_notify / comment_notify.migrate.inc @ 87dbc3bf

1
<?php
2

    
3
/**
4
 * @file
5
 * Migration support for the Comment Notify module.
6
 */
7

    
8
/**
9
 * Field handler.
10
 */
11
class CommentNotifyMigrationHandler extends MigrateDestinationHandler {
12
  public function __construct() {
13
    $this->registerTypes(array('comment'));
14
  }
15

    
16
  /**
17
   * Make the destination field visible.
18
   */
19
  public function fields() {
20
    return array(
21
      'notify' => t('Comment Notify: Whether to send notifications for this comment'),
22
      'notified' => t('Comment Notify: Whether notifications have been sent for this comment'),
23
      'notify_hash' => t('Comment Notify: Hash representing this notification'),
24
    );
25
  }
26

    
27
  /**
28
   * Implements MigrateDestinationHandler::prepare().
29
   *
30
   * @param $comment
31
   *  The comment object being prepared for saving.
32
   * @param $row
33
   *  Raw source data for the migration - ignored.
34
   */
35
  public function prepare($comment, $row) {
36
    // By default, set notifications off
37
    if (!isset($comment->notify)) {
38
      $comment->notify = 0;
39
    }
40
    if (!isset($comment->notify_type)) {
41
      $comment->notify_type = 1;
42
    }
43
  }
44

    
45
  /**
46
   * Implements MigrateDestinationHandler::complete().
47
   *
48
   * @param $comment
49
   *  The comment object taht was just saved.
50
   * @param $row
51
   *  Raw source data for the migration - ignored.
52
   */
53
  public function complete($comment, $row) {
54
    if (!isset($comment->notified) || $comment->notified) {
55
      comment_notify_mark_comment_as_notified($comment);
56
    }
57
  }
58
}
59

    
60
/*
61
 * Implementats hook_migrate_api().
62
 */
63
function comment_notify_migrate_api() {
64
  $api = array(
65
    'api' => 2,
66
  );
67
  return $api;
68
}