You are here

public function ArticleNode::prepareRow in Import 8

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

File

src/Plugin/migrate/source/ArticleNode.php, line 20
Contains \Drupal\import\Plugin\migrate\source\ArticleNode.

Class

ArticleNode
Source for Article node CSV.

Namespace

Drupal\import\Plugin\migrate\source

Code

public function prepareRow(Row $row) {
  if ($value = $row
    ->getSourceProperty('Tags')) {
    $row
      ->setSourceProperty('Tags', explode(',', $value));
  }
  if ($value = $row
    ->getSourceProperty('Image')) {
    $path = dirname($this->configuration['path']) . '/images/' . $value;
    $data = file_get_contents($path);
    $uri = file_build_uri($value);
    $file = file_save_data($data, $uri);
    $row
      ->setSourceProperty('Image', $file);
  }
}