You are here

public function ForwardStatistics::import in Forward 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/migrate/destination/ForwardStatistics.php \Drupal\forward\Plugin\migrate\destination\ForwardStatistics::import()
  2. 8.2 src/Plugin/migrate/destination/ForwardStatistics.php \Drupal\forward\Plugin\migrate\destination\ForwardStatistics::import()
  3. 4.x src/Plugin/migrate/destination/ForwardStatistics.php \Drupal\forward\Plugin\migrate\destination\ForwardStatistics::import()
  4. 4.0.x src/Plugin/migrate/destination/ForwardStatistics.php \Drupal\forward\Plugin\migrate\destination\ForwardStatistics::import()

Import the row.

Derived classes must implement import(), to construct one new object (pre-populated) using ID mappings in the Migration.

Parameters

\Drupal\migrate\Row $row: The row object.

array $old_destination_id_values: (optional) The old destination IDs. Defaults to an empty array.

Return value

array|bool An indexed array of destination IDs in the same order as defined in the plugin's getIds() method if the plugin wants to save the IDs to the ID map, TRUE to indicate success without saving IDs to the ID map, or FALSE to indicate a failure.

Overrides MigrateDestinationInterface::import

File

src/Plugin/migrate/destination/ForwardStatistics.php, line 20

Class

ForwardStatistics
Drupal 8 destination for forward statistics.

Namespace

Drupal\forward\Plugin\migrate\destination

Code

public function import(Row $row, array $old_destination_id_values = array()) {
  $destination = $row
    ->getDestination();
  $this->database
    ->merge('forward_statistics')
    ->key(array(
    'type' => $destination['type'],
    'id' => $destination['id'],
  ))
    ->fields(array(
    'type' => $destination['type'],
    'bundle' => $destination['bundle'],
    'id' => $destination['id'],
    'last_forward_timestamp' => $destination['last_forward_timestamp'],
    'forward_count' => $destination['forward_count'],
    'clickthrough_count' => $destination['clickthrough_count'],
  ))
    ->execute();
  return [
    $row
      ->getDestinationProperty('type'),
    $row
      ->getDestinationProperty('bundle'),
    $row
      ->getDestinationProperty('id'),
  ];
}