You are here

class CommentNotifyMigrationHandler in Comment Notify 7

Same name and namespace in other branches
  1. 8 comment_notify.migrate.inc \CommentNotifyMigrationHandler

Field handler.

Hierarchy

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 {
  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 object $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 object $comment
   *   The comment object that 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

Namesort descending Modifiers Type Description Overrides
CommentNotifyMigrationHandler::complete public function Implements MigrateDestinationHandler::complete().
CommentNotifyMigrationHandler::fields public function Make the destination field visible.
CommentNotifyMigrationHandler::prepare public function Implements MigrateDestinationHandler::prepare().
CommentNotifyMigrationHandler::__construct public function Overrides MigrateHandler::__construct
MigrateHandler::$dependencies protected property List of other handler classes which should be invoked before the current one.
MigrateHandler::$typesHandled protected property List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc.
MigrateHandler::getDependencies public function
MigrateHandler::getTypesHandled public function
MigrateHandler::handlesType public function Does this handler handle the given type? 1
MigrateHandler::registerTypes protected function Register a list of types handled by this class