You are here

public function RoomsUnitMigration::__construct in Rooms - Drupal Booking for Hotels, B&Bs and Vacation Rentals 7

General initialization of a Migration object.

Overrides Migration::__construct

File

modules/rooms_unit/rooms_unit.migrate.inc, line 227
Class MigrateDestinationRoomsUnit.

Class

RoomsUnitMigration
Base Migration class that imports bookable units from a csv file.

Code

public function __construct($args) {
  parent::__construct($args);
  $this->description = t('Import Rooms units of type "@type" from the file @file', array(
    '@type' => $args['type'],
    '@file' => $args['file'],
  ));

  // Create a map object for tracking the relationships between source rows
  $this->map = new MigrateSQLMap($this->machineName, array(
    'row_id' => array(
      'type' => 'int',
      'length' => 10,
      'not null' => TRUE,
    ),
  ), MigrateDestinationRoomsUnit::getKeySchema());

  // Create a MigrateSource object.
  $this->source = new MigrateSourceCSV($args['file'], $this
    ->unit_csvcolumns(), array(
    'header_rows' => 1,
  ));

  // Create a MigrateDestination object.
  $this->destination = new MigrateDestinationRoomsUnit($args['type']);

  // Field mappings
  $this
    ->addFieldMapping('name', 'name');
  $this
    ->addFieldMapping('base_price', 'base_price');
  $this
    ->addFieldMapping('default_state', 'default_state');
  $this
    ->addFieldMapping('bookable', 'bookable');
  $this
    ->addFieldMapping('min_sleeps', 'min_sleeps');
  $this
    ->addFieldMapping('max_sleeps', 'max_sleeps');
  $this
    ->addFieldMapping('min_children', 'min_children');
  $this
    ->addFieldMapping('max_children', 'max_children');

  // Bed arrangement, will be automatically inserted into ->data['bed_arrangement'].
  $this
    ->addFieldMapping('singles', 'singles');
  $this
    ->addFieldMapping('doubles', 'doubles');
  $this
    ->addUnmigratedDestinations(array(
    'data',
    'path',
    'type',
  ));
}