Overrides Drupal\Core\Entity\EntityFormController::save().
Overrides EntityFormController::save
public function save(array $form, array &$form_state) {
$term = $this->entity;
switch ($term
->save()) {
case SAVED_NEW:
drupal_set_message(t('Created new term %term.', array(
'%term' => $term
->label(),
)));
watchdog('taxonomy', 'Created new term %term.', array(
'%term' => $term
->label(),
), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $term
->id() . '/edit'));
break;
case SAVED_UPDATED:
drupal_set_message(t('Updated term %term.', array(
'%term' => $term
->label(),
)));
watchdog('taxonomy', 'Updated term %term.', array(
'%term' => $term
->label(),
), WATCHDOG_NOTICE, l(t('edit'), 'taxonomy/term/' . $term
->id() . '/edit'));
// Clear the page and block caches to avoid stale data.
cache_invalidate_tags(array(
'content' => TRUE,
));
break;
}
$current_parent_count = count($form_state['values']['parent']);
$previous_parent_count = count($form_state['taxonomy']['parent']);
// Root doesn't count if it's the only parent.
if ($current_parent_count == 1 && isset($form_state['values']['parent'][0])) {
$current_parent_count = 0;
$form_state['values']['parent'] = array();
}
// If the number of parents has been reduced to one or none, do a check on the
// parents of every term in the vocabulary value.
if ($current_parent_count < $previous_parent_count && $current_parent_count < 2) {
taxonomy_check_vocabulary_hierarchy($form_state['taxonomy']['vocabulary'], $form_state['values']);
}
elseif ($current_parent_count > $previous_parent_count && $form_state['taxonomy']['vocabulary']->hierarchy != TAXONOMY_HIERARCHY_MULTIPLE) {
$form_state['taxonomy']['vocabulary']->hierarchy = $current_parent_count == 1 ? TAXONOMY_HIERARCHY_SINGLE : TAXONOMY_HIERARCHY_MULTIPLE;
$form_state['taxonomy']['vocabulary']
->save();
}
$form_state['values']['tid'] = $term
->id();
$form_state['tid'] = $term
->id();
}