You are here

public function PanopolyDemoMenu::__construct in Panopoly Demo 7

General initialization of a Migration object.

Overrides Migration::__construct

File

import/panopoly_demo.menu.inc, line 10
Migrations for Menu items.

Class

PanopolyDemoMenu
@file Migrations for Menu items.

Code

public function __construct(array $arguments) {
  parent::__construct($arguments);
  $this->description = t('Import menu items.');
  $this->dependencies = array(
    'PanopolyDemoNode',
  );

  // Create a map object for tracking the relationships between source rows.
  $this->map = new MigrateSQLMap($this->machineName, array(
    'mlid' => array(
      'type' => 'int',
      'unsigned' => TRUE,
      'not null' => TRUE,
      'description' => 'ID of destination link',
    ),
  ), MigrateDestinationMenuLinks::getKeySchema());
  $import_path = drupal_get_path('module', 'panopoly_demo') . '/import/data/';

  // Create a MigrateSource object.
  $this->source = new MigrateSourceCSV($import_path . 'panopoly_demo.menu.csv', $this
    ->csvcolumns(), array(
    'header_rows' => 1,
  ));
  $this->destination = new MigrateDestinationMenuLinks('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');
  $this
    ->addFieldMapping('menu_name')
    ->defaultValue('main-menu');
  $this
    ->addFieldMapping('plid', 'ref_parent')
    ->sourceMigration($this
    ->getMachineName());
  $this
    ->addFieldMapping('link_path', 'path');
  $this
    ->addFieldMapping('router_path')
    ->defaultValue('node/%');
  $this
    ->addFieldMapping('link_title', 'title');
  $this
    ->addFieldMapping('external')
    ->defaultValue('0');
  $this
    ->addFieldMapping('expanded')
    ->defaultValue('0');
  $this
    ->addFieldMapping('weight', 'weight');
  $this
    ->addFieldMapping('customized')
    ->defaultValue('1');
  $this
    ->addFieldMapping('has_children')
    ->defaultValue('0');
  $this
    ->addFieldMapping('depth')
    ->defaultValue('1');
  $this
    ->addUnmigratedDestinations(array(
    'module',
    'hidden',
    'options',
    'p1',
    'p2',
    'p3',
    'p4',
    'p5',
    'p6',
    'p7',
    'p8',
    'p9',
    'updated',
  ));
}