You are here

class ArticleNode 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

Source for Article node CSV.

Plugin annotation


@MigrateSource(
  id = "article_node"
)

Hierarchy

  • class \Drupal\import\Plugin\migrate\source\ArticleNode extends \Drupal\migrate_source_csv\Plugin\migrate\source\CSV

Expanded class hierarchy of ArticleNode

File

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

Namespace

Drupal\import\Plugin\migrate\source
View source
class ArticleNode extends CSV {
  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);
    }
  }

}

Members