private static function Terms::createNewTerm in Hook Update Deploy Tools 7
Create a Term from the imported object.
Parameters
object $term: The Term object from the import file.
Return value
object The resulting Term from term_save, broken free of reference to $term.
1 call to Terms::createNewTerm()
- Terms::importOne in src/
Terms.php - Validated Updates/Imports one term from the contents of an import file.
File
- src/
Terms.php, line 402
Class
- Terms
- Public methods for dealing with Vocabularies.
Namespace
HookUpdateDeployToolsCode
private static function createNewTerm($term) {
$saved_term = clone $term;
// Remove the tid as it will be assigned one upon save.
unset($saved_term->tid);
// Need to lookup the vocabulary since vid may be different.
$vocabulary = Vocabularies::loadByMachineName($saved_term->vocabulary_machine_name, TRUE);
$saved_term->vid = $vocabulary->vid;
// @TODO Need to add handling for field collections.
// @TODO Need to add handling for entity references.
taxonomy_term_save($saved_term);
return $saved_term;
}