diff --git a/core/modules/statistics/migration_templates/d7_statistics_node_counter.yml b/core/modules/statistics/migration_templates/d7_statistics_node_counter.yml new file mode 100644 index 0000000..abb7695 --- /dev/null +++ b/core/modules/statistics/migration_templates/d7_statistics_node_counter.yml @@ -0,0 +1,19 @@ +id: d7_statistics_node_counter +label: Drupal 7 Node Counter +migration_tags: + - Drupal 7 +source: + plugin: d7_node_counter +process: + nid: + plugin: migration + migration: d7_node + source: nid + totalcount: totalcount + daycount: daycount + timestamp: timestamp +destination: + plugin: node_counter +migration_dependencies: + required: + - d7_node diff --git a/core/modules/statistics/src/Plugin/migrate/destination/NodeCounter.php b/core/modules/statistics/src/Plugin/migrate/destination/NodeCounter.php new file mode 100644 index 0000000..139a0ec --- /dev/null +++ b/core/modules/statistics/src/Plugin/migrate/destination/NodeCounter.php @@ -0,0 +1,85 @@ + ['type' => 'int']]; + } + + /** + * {@inheritdoc} + */ + public function fields(MigrationInterface $migration = NULL) { + return [ + 'nid' => $this->t('The nid of the node for these statistics.'), + 'totalcount' => $this->t('The total number of times the node has been viewed.'), + 'daycount' => $this->t('The total number of times the node has been viewed today.'), + 'timestamp' => $this->t('The most recent time the node has been viewed.'), + ]; + } + + /** + * {@inheritdoc} + */ + public function import(Row $row, array $old_destination_id_values = array()) { + $nid = $row->getDestinationProperty('nid'); + $totalcount = $row->getDestinationProperty('totalcount'); + $daycount = $row->getDestinationProperty('daycount'); + $timestamp = $row->getDestinationProperty('timestamp'); + + // @todo Save the statistics. + } + +}