You are here

public function RelationType::preSave in Relation 8

Same name and namespace in other branches
  1. 8.2 src/Entity/RelationType.php \Drupal\relation\Entity\RelationType::preSave()

Acts on an entity before the presave hook is invoked.

Used before the entity is saved and before invoking the presave hook.

Ensure that config entities which are bundles of other entities cannot have their ID changed.

Parameters

\Drupal\Core\Entity\EntityStorageInterface $storage: The entity storage object.

Throws

\Drupal\Core\Config\ConfigNameException Thrown when attempting to rename a bundle entity.

Overrides ConfigEntityBundleBase::preSave

File

src/Entity/RelationType.php, line 186

Class

RelationType
Defines relation type entity.

Namespace

Drupal\relation\Entity

Code

public function preSave(EntityStorageInterface $storage) {
  parent::preSave($storage);
  if (empty($this->label)) {
    $this->label = $this
      ->id();
  }

  // Directional relations should have a reverse label. If they are symmetric
  // or if they don't have it, fill it with the label.
  if (empty($this->reverse_label)) {
    $this->reverse_label = $this->label;
  }
}