You are here

public function FieldInheritance::save in Field Inheritance 8

Same name and namespace in other branches
  1. 2.0.x src/Entity/FieldInheritance.php \Drupal\field_inheritance\Entity\FieldInheritance::save()

Saves an entity permanently.

When saving existing entities, the entity is assumed to be complete, partial updates of entities are not supported.

Return value

int Either SAVED_NEW or SAVED_UPDATED, depending on the operation performed.

Throws

\Drupal\Core\Entity\EntityStorageException In case of failures an exception is thrown.

Overrides ConfigEntityBase::save

File

src/Entity/FieldInheritance.php, line 257

Class

FieldInheritance
Defines the Field inheritance entity.

Namespace

Drupal\field_inheritance\Entity

Code

public function save() {
  if (strpos($this
    ->id(), $this
    ->destinationEntityType() . '_' . $this
    ->destinationEntityBundle() . '_') === FALSE) {
    $this->id = $this
      ->destinationEntityType() . '_' . $this
      ->destinationEntityBundle() . '_' . $this
      ->id();
  }
  parent::save();
}