public function WineProducerMigration::__construct in Migrate 7.2
Same name and namespace in other branches
- 6.2 migrate_example/wine.inc \WineProducerMigration::__construct()
General initialization of a Migration object.
Overrides AdvancedExampleMigration::__construct
File
- migrate_example/
wine.inc, line 439 - Advanced migration examples. These serve two purposes:
Class
Code
public function __construct($arguments) {
parent::__construct($arguments);
$this->description = t('Wine producers of the world');
$this->map = new MigrateSQLMap($this->machineName, array(
'producerid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'alias' => 'p',
),
), MigrateDestinationNode::getKeySchema());
$query = db_select('migrate_example_wine_producer', 'p')
->fields('p', array(
'producerid',
'name',
'body',
'excerpt',
'accountid',
));
// Region term is singletons, handled straighforwardly
$query
->leftJoin('migrate_example_wine_category_producer', 'reg', 'p.producerid = reg.producerid');
$query
->addField('reg', 'categoryid', 'region');
$this->source = new MigrateSourceSQL($query);
$this->destination = new MigrateDestinationNode('migrate_example_producer');
// Mapped fields
$this
->addFieldMapping('title', 'name')
->description(t('Mapping producer name in source to node title'));
$this
->addFieldMapping('uid', 'accountid')
->sourceMigration('WineUser')
->defaultValue(1);
$this
->addFieldMapping('migrate_example_wine_regions', 'region')
->sourceMigration('WineRegion');
$this
->addFieldMapping('migrate_example_wine_regions:source_type')
->defaultValue('tid');
$this
->addFieldMapping('body', 'body');
$this
->addFieldMapping('body:summary', 'excerpt');
$this
->addFieldMapping('sticky')
->defaultValue(0);
// No unmapped source fields
// Unmapped destination fields
$this
->addUnmigratedDestinations(array(
'body:format',
'changed',
'comment',
'created',
'is_new',
'language',
'log',
'promote',
'revision',
'revision_uid',
'status',
'tnid',
'translate',
'migrate_example_wine_regions:create_term',
'migrate_example_wine_regions:ignore_case',
));
if (module_exists('statistics')) {
$this
->addUnmigratedDestinations(array(
'totalcount',
'daycount',
'timestamp',
));
}
}