You are here

public function ImageFile::prepareRow in Import 8

Same name and namespace in other branches
  1. 8.2 src/Plugin/migrate/source/ImageFile.php \Drupal\import\Plugin\migrate\source\ImageFile::prepareRow()

File

src/Plugin/migrate/source/ImageFile.php, line 22
Contains \Drupal\import\Plugin\migrate\source\ImageFile.

Class

ImageFile
Source for Image csv.

Namespace

Drupal\import\Plugin\migrate\source

Code

public function prepareRow(Row $row) {
  if ($image = $row
    ->getSourceProperty('File')) {
    $base_path = dirname($this->configuration['path']) . '/images/';

    // Setup our source/destination paths.
    $path = $base_path . $image;
    $destination_path = 'public://' . $image;

    // Normally we would map CSV columns to these values, but to reduce
    // complexity we assume paths and status.
    $row
      ->setSourceProperty('filepath', $path);
    $row
      ->setDestinationProperty('uri', $destination_path);
    $row
      ->setDestinationProperty('status', 1);
  }
}