Overrides Drupal\Core\Config\Entity\ConfigStorageController::postSave().
Overrides ConfigStorageController::postSave
protected function postSave(EntityInterface $entity, $update) {
if (!$update) {
entity_invoke_bundle_hook('create', 'taxonomy_term', $entity
->id());
}
elseif ($entity
->getOriginalID() != $entity
->id()) {
// Reflect machine name changes in the definitions of existing 'taxonomy'
// fields.
$fields = field_read_fields();
foreach ($fields as $field_name => $field) {
$update_field = FALSE;
if ($field['type'] == 'taxonomy_term_reference') {
foreach ($field['settings']['allowed_values'] as $key => &$value) {
if ($value['vocabulary'] == $entity
->getOriginalID()) {
$value['vocabulary'] = $entity
->id();
$update_field = TRUE;
}
}
if ($update_field) {
field_update_field($field);
}
}
}
// Update bundles.
entity_invoke_bundle_hook('rename', 'taxonomy_term', $entity
->getOriginalID(), $entity
->id());
}
parent::postSave($entity, $update);
$this
->resetCache($update ? array(
$entity
->getOriginalID(),
) : array());
}