diff --git a/core/modules/statistics/src/Plugin/migrate/destination/NodeCounter.php b/core/modules/statistics/src/Plugin/migrate/destination/NodeCounter.php index 139a0ec..38f266c 100644 --- a/core/modules/statistics/src/Plugin/migrate/destination/NodeCounter.php +++ b/core/modules/statistics/src/Plugin/migrate/destination/NodeCounter.php @@ -1,42 +1,46 @@ connection = $connection; } /** @@ -47,7 +51,8 @@ public static function create(ContainerInterface $container, array $configuratio $configuration, $plugin_id, $plugin_definition, - $migration + $migration, + $container->get('database') ); } @@ -63,7 +68,7 @@ public function getIds() { */ public function fields(MigrationInterface $migration = NULL) { return [ - 'nid' => $this->t('The nid of the node for these statistics.'), + 'nid' => $this->t('The ID of the node to which these statistics apply.'), '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.'), @@ -74,12 +79,20 @@ public function fields(MigrationInterface $migration = NULL) { * {@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. + return (bool) $this->connection + ->insert('node_counter') + ->fields([ + 'nid', + 'daycount', + 'totalcount', + 'timestamp', + ], [ + $row->getDestinationProperty('nid'), + $row->getDestinationProperty('daycount'), + $row->getDestinationProperty('totalcount'), + $row->getDestinationProperty('timestamp'), + ]) + ->execute(); } }