You are here

public function PanopolyDemoNode::__construct in Panopoly Demo 7

General initialization of a Migration object.

Overrides Migration::__construct

File

import/panopoly_demo.node.inc, line 10
Migrations for Basic Nodes.

Class

PanopolyDemoNode
@file Migrations for Basic Nodes.

Code

public function __construct(array $arguments) {
  parent::__construct($arguments);
  $this->description = t('Import nodes.');

  // Create a map object for tracking the relationships between source rows.
  $this->map = new MigrateSQLMap($this->machineName, array(
    'title' => array(
      'type' => 'varchar',
      'length' => 255,
      'not null' => TRUE,
    ),
  ), MigrateDestinationNode::getKeySchema());
  $import_path = drupal_get_path('module', 'panopoly_demo') . '/import/data/';

  // Create a MigrateSource object.
  $this->source = new MigrateSourceCSV($import_path . 'panopoly_demo.node.csv', $this
    ->csvcolumns(), array(
    'header_rows' => 1,
  ));
  $this->destination = new MigrateDestinationNode('panopoly_page');
  $this
    ->addFieldMapping('uid')
    ->defaultValue(1);
  $this
    ->addFieldMapping('status')
    ->defaultValue(1);
  $this
    ->addFieldMapping('language')
    ->defaultValue(LANGUAGE_NONE);
  $this
    ->addFieldMapping('title', 'title');
  $this
    ->addFieldMapping('field_featured_image', 'image');
  $this
    ->addFieldMapping('field_featured_image:file_replace')
    ->defaultValue(FILE_EXISTS_REPLACE);
  $this
    ->addFieldMapping('field_featured_image:source_dir')
    ->defaultValue(drupal_get_path('module', 'panopoly_demo') . '/import/images');
  $this
    ->addFieldMapping('body', 'body');
  $this
    ->addFieldMapping('body:format')
    ->defaultValue('panopoly_wysiwyg_text');
  $this
    ->addFieldMapping('field_featured_status', 'featured');
  $this
    ->addFieldMapping('created', 'created');
}