You are here

public static function EntityShareTaxonomyImport::setLocalVocabularyId in Entity Share 7

Set the exported vocabulary to the local vocabulary id.

Parameters

object $term: Entity or sub entity to import.

Return value

bool TRUE if success, FALSE otherwise.

Throws

EntityShareImportException Exception thrown in case of unexisting vocabulary locally.

2 calls to EntityShareTaxonomyImport::setLocalVocabularyId()
EntityShareTaxonomyImport::setLocalIds in modules/entity_share_taxonomy/includes/entity_share_taxonomy.import.inc
Set the local ids.
entity_share_taxonomy_es_import_local_entities_alter in modules/entity_share_taxonomy/entity_share_taxonomy.module
Implements hook_es_import_local_entities_alter().

File

modules/entity_share_taxonomy/includes/entity_share_taxonomy.import.inc, line 60
Class for handling Taxonomy Import.

Class

EntityShareTaxonomyImport
A class to import the Taxonomy.

Code

public static function setLocalVocabularyId($term) {
  $entity_info = entity_get_info($term->entity_type);
  $vocabulary_machine_name = $term->{$entity_info['entity keys']['bundle']};
  $vocabulary = taxonomy_vocabulary_machine_name_load($vocabulary_machine_name);
  if (!isset($vocabulary->vid)) {
    watchdog(self::WATCHDOG_TYPE, 'The vocabulary %vocabulary doesn\'t exist', array(
      '%vocabulary' => $vocabulary_machine_name,
    ), WATCHDOG_ERROR);
    throw new EntityShareImportException('The vocabulary ' . $vocabulary_machine_name . ' doesn\'t exist');
  }
  $term->vid = $vocabulary->vid;
  return TRUE;
}