You are here

public function PhotosComment::import in Album Photos 8.5

Same name and namespace in other branches
  1. 8.4 src/Plugin/migrate/destination/PhotosComment.php \Drupal\photos\Plugin\migrate\destination\PhotosComment::import()
  2. 6.0.x src/Plugin/migrate/destination/PhotosComment.php \Drupal\photos\Plugin\migrate\destination\PhotosComment::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/PhotosComment.php, line 36

Class

PhotosComment
Photos comment migration destination.

Namespace

Drupal\photos\Plugin\migrate\destination

Code

public function import(Row $row, array $old_destination_id_values = []) {

  // @todo migrate to new photos_image comment type.
  // @todo add fields to comment type if needed.
  $db = \Drupal::database();
  $db
    ->insert('photos_comment')
    ->fields([
    'fid' => $row
      ->getDestinationProperty('fid'),
    'cid' => $row
      ->getDestinationProperty('cid'),
  ])
    ->execute();
  return [
    $row
      ->getDestinationProperty('fid'),
    $row
      ->getDestinationProperty('cid'),
  ];
}