Skip to content
This repository has been archived by the owner on May 4, 2020. It is now read-only.

Commit

Permalink
Add support for Entity registration
Browse files Browse the repository at this point in the history
  • Loading branch information
Pedro Cambra committed Oct 28, 2014
1 parent 42351c8 commit 93a8e8f
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions migrate_default_content.module
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ function migrate_default_content_get_config_files($content_path = '') {

/**
* Fetches the migration files and returns its information.
*
*
* @return array
*/
function migrate_default_content_fetch_migrations() {
Expand Down Expand Up @@ -117,13 +117,16 @@ function migrate_default_content_flush_caches() {

/**
* Implements hook_entity_presave().
*
* Workaround for a bug when saving taxonomy_term entities:
* In taxonomy_term_save $term->vocabulary_machine_name is not converted to vid.
*/
function migrate_default_content_entity_presave($entity, $type) {
if ($type == "taxonomy_term" && empty($entity->vid) && $entity->vocabulary_machine_name) {
// loads taxonomy vocabulary and assigns its vid to the taxonomy term.
// Transform machine name to vid on taxonomy_term_save().
if ($type == 'taxonomy_term' && empty($entity->vid) && $entity->vocabulary_machine_name) {
// Loads taxonomy vocabulary and assigns its vid to the taxonomy term.
$entity->vid = taxonomy_vocabulary_machine_name_load($entity->vocabulary_machine_name)->vid;
}

// Support entity registration.
if ($type == 'registration' && isset($entity->entity)) {
$entity->entity_id = $entity->entity['destid1'];
}
}

0 comments on commit 93a8e8f

Please sign in to comment.