connection = $connection; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) { return new static( $configuration, $plugin_id, $plugin_definition, $migration, $container->get('database') ); } /** * {@inheritdoc} */ public function getIds() { return ['nid' => ['type' => 'integer']]; } /** * {@inheritdoc} */ public function fields(MigrationInterface $migration = NULL) { return [ '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.'), ]; } /** * {@inheritdoc} */ public function import(Row $row, array $old_destination_id_values = []) { $this->connection ->insert('node_counter') ->fields([ 'nid' => $row->getDestinationProperty('nid'), 'daycount' => $row->getDestinationProperty('daycount'), 'totalcount' => $row->getDestinationProperty('totalcount'), 'timestamp' => $row->getDestinationProperty('timestamp'), ]) ->execute(); return [$row->getDestinationProperty('nid')]; } }