private static function Terms::rollbackImport in Hook Update Deploy Tools 7
Rolls back a term to its original state or deletes a creation.
Parameters
string $op: The crud op that was performed.
object $term: The term's original state to roll back to.
1 call to Terms::rollbackImport()
- Terms::importOne in src/
Terms.php - Validated Updates/Imports one term from the contents of an import file.
File
- src/
Terms.php, line 359
Class
- Terms
- Public methods for dealing with Vocabularies.
Namespace
HookUpdateDeployToolsCode
private static function rollbackImport($op, $term) {
$variables = array(
'@tid' => $term->tid,
'@name' => $term->name,
'@op' => $op,
);
if ($op === 'create') {
// Op was a create, so delete the Term if there was one created.
if (!empty($term->tid)) {
// The presence of tid indicates one was created, so delete it.
taxonomy_term_delete($term->tid);
$msg = "Term @name(@tid) was @opd but failed validation and was deleted.";
}
else {
// Create was attempted but not completed. Nothing to roll back.
$msg = "The term:@name failed @op and had nothing to roll back.";
}
}
else {
// Op was an update, so attempt to swap in the original term.
if (!empty($term->original)) {
// The original values are available, so re-set them.
taxonomy_term_save($term->original);
$msg = "Term @name(@tid) @opd but failed validation, The term was rolled back to its previous state. Verify manually.";
}
else {
$msg = "Term @name(@tid) @opd but failed validation. An original copy was not available to roll back. Verify manually";
}
}
Message::make($msg, $variables, WATCHDOG_INFO, 2);
}