function NodeCounter::import
Same name in other branches
- 8.9.x core/modules/statistics/src/Plugin/migrate/destination/NodeCounter.php \Drupal\statistics\Plugin\migrate\destination\NodeCounter::import()
- 10 core/modules/statistics/src/Plugin/migrate/destination/NodeCounter.php \Drupal\statistics\Plugin\migrate\destination\NodeCounter::import()
- 11.x core/modules/statistics/src/Plugin/migrate/destination/NodeCounter.php \Drupal\statistics\Plugin\migrate\destination\NodeCounter::import()
Overrides MigrateDestinationInterface::import
File
-
core/
modules/ statistics/ src/ Plugin/ migrate/ destination/ NodeCounter.php, line 83
Class
- NodeCounter
- Destination for node counter.
Namespace
Drupal\statistics\Plugin\migrate\destinationCode
public function import(Row $row, array $old_destination_id_values = []) {
$nid = $row->getDestinationProperty('nid');
$daycount = $row->getDestinationProperty('daycount');
$totalcount = $row->getDestinationProperty('totalcount');
$timestamp = $row->getDestinationProperty('timestamp');
$this->connection
->merge('node_counter')
->key('nid', $nid)
->fields([
'daycount' => $daycount,
'totalcount' => $totalcount,
'timestamp' => $timestamp,
])
->expression('daycount', '[daycount] + :daycount', [
':daycount' => $daycount,
])
->expression('totalcount', '[totalcount] + :totalcount', [
':totalcount' => $totalcount,
])
->expression('timestamp', 'CASE WHEN [timestamp] > :timestamp1 THEN [timestamp] ELSE :timestamp2 END', [
':timestamp1' => $timestamp,
':timestamp2' => $timestamp,
])
->execute();
return [
$row->getDestinationProperty('nid'),
];
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.