You are here

class MigrateStatisticsEntityHandler in Migrate 6.2

Same name and namespace in other branches
  1. 7.2 plugins/destinations/statistics.inc \MigrateStatisticsEntityHandler

@file Support for node_counter statistics in core Drupal nodes

Hierarchy

Expanded class hierarchy of MigrateStatisticsEntityHandler

1 string reference to 'MigrateStatisticsEntityHandler'
migrate_migrate_api in ./migrate.module

File

plugins/destinations/statistics.inc, line 7
Support for node_counter statistics in core Drupal nodes

View source
class MigrateStatisticsEntityHandler extends MigrateDestinationHandler {
  public function __construct() {
    $this
      ->registerTypes(array(
      'node',
    ));
  }
  public function fields() {
    if (module_exists('statistics')) {
      $fields = array(
        'totalcount' => t('Node: The total number of times the node has been viewed.'),
        'daycount' => t('Node: The total number of times the node has been viewed today.'),
        'timestamp' => t('Node: The most recent time the node has been viewed.'),
      );
    }
    else {
      $fields = array();
    }
    return $fields;
  }
  public function complete($node, stdClass $row) {
    if (module_exists('statistics') && isset($node->nid)) {
      $totalcount = isset($node->totalcount) ? $node->totalcount : 0;
      $daycount = isset($node->daycount) ? $node->daycount : 0;
      $timestamp = isset($node->timestamp) ? $node->timestamp : 0;
      db_merge('node_counter')
        ->key(array(
        'nid' => $node->nid,
      ))
        ->fields(array(
        'totalcount' => $totalcount,
        'daycount' => $daycount,
        'timestamp' => $timestamp,
      ))
        ->execute();
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
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?
MigrateHandler::registerTypes protected function Register a list of types handled by this class
MigrateStatisticsEntityHandler::complete public function
MigrateStatisticsEntityHandler::fields public function
MigrateStatisticsEntityHandler::__construct public function Overrides MigrateHandler::__construct