1 taxonomy.entity.inc protected TaxonomyTermController::postSave(EntityInterface $entity, $update)

Overrides EntityDatabaseStorageController::postSave().

Parameters

TaxonomyTerm $entity: The term entity that was just saved.

Overrides EntityDatabaseStorageController::postSave

File

core/modules/taxonomy/taxonomy.entity.inc, line 272
Entity classes and controllers for Taxonomy module.

Class

TaxonomyTermController
Controller class for taxonomy terms.

Code

protected function postSave(EntityInterface $entity, $update) {
  if (isset($entity->parent)) {
    db_delete('taxonomy_term_hierarchy')
      ->condition('tid', $entity->tid)
      ->execute();

    $query = db_insert('taxonomy_term_hierarchy')
      ->fields(array('tid', 'parent'));

    foreach ($entity->parent as $parent) {
      $query->values(array(
        'tid' => $entity->tid,
        'parent' => $parent
      ));
    }
    $query->execute();
  }
}