Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. Term.php

function Term::preSave

Overrides ContentEntityBase::preSave

File

core/modules/taxonomy/src/Entity/Term.php, line 137

Class

Term
Defines the taxonomy term entity.

Namespace

Drupal\taxonomy\Entity

Code

public function preSave(EntityStorageInterface $storage) {
    parent::preSave($storage);
    // Terms with no parents are mandatory children of <root>.
    if (!$this->get('parent')
        ->count()) {
        $this->parent->target_id = 0;
    }
}
RSS feed
Powered by Drupal