class MigrateStatisticsEntityHandler in Migrate 7.2
Same name and namespace in other branches
- 6.2 plugins/destinations/statistics.inc \MigrateStatisticsEntityHandler
@file Support for node_counter statistics in core Drupal nodes.
Hierarchy
- class \MigrateHandler
- class \MigrateDestinationHandler
Expanded class hierarchy of MigrateStatisticsEntityHandler
1 string reference to 'MigrateStatisticsEntityHandler'
File
- plugins/
destinations/ statistics.inc, line 8 - Support for node_counter statistics in core Drupal nodes.
View source
class MigrateStatisticsEntityHandler extends MigrateDestinationHandler {
public function __construct() {
$this
->registerTypes(array(
'node',
));
}
/**
* Implementation of MigrateDestinationHandler::fields().
*/
public function fields($entity_type, $bundle, $migration = NULL) {
if (module_exists('statistics')) {
$fields = array(
'totalcount' => t('The total number of times the node has been viewed.'),
'daycount' => t('The total number of times the node has been viewed today.'),
'timestamp' => t('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) && is_numeric($node->totalcount) ? $node->totalcount : 0;
$daycount = isset($node->daycount) && is_numeric($node->daycount) ? $node->daycount : 0;
$timestamp = isset($node->timestamp) && is_numeric($node->timestamp) ? $node->timestamp : 0;
db_merge('node_counter')
->key(array(
'nid' => $node->nid,
))
->fields(array(
'totalcount' => $totalcount,
'daycount' => $daycount,
'timestamp' => $timestamp,
))
->execute();
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MigrateHandler:: |
protected | property | List of other handler classes which should be invoked before the current one. | |
MigrateHandler:: |
protected | property | List of "types" handled by this handler. Depending on the kind of handler, these may be destination types, field types, etc. | |
MigrateHandler:: |
public | function | ||
MigrateHandler:: |
public | function | ||
MigrateHandler:: |
public | function | Does this handler handle the given type? | 1 |
MigrateHandler:: |
protected | function | Register a list of types handled by this class | |
MigrateStatisticsEntityHandler:: |
public | function | ||
MigrateStatisticsEntityHandler:: |
public | function | Implementation of MigrateDestinationHandler::fields(). | |
MigrateStatisticsEntityHandler:: |
public | function |
Overrides MigrateHandler:: |