You are here

public function UnsavedIndexConfiguration::save in Search API 8

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 EntityInterface::save

File

src/UnsavedIndexConfiguration.php, line 873

Class

UnsavedIndexConfiguration
Represents a configuration of an index that was not yet permanently saved.

Namespace

Drupal\search_api

Code

public function save() {
  try {
    if ($this->tempStore
      ->setIfOwner($this->entity
      ->id(), $this->entity)) {
      return SAVED_UPDATED;
    }
  } catch (TempStoreException $e) {
    throw new EntityStorageException('Could not save temporary index configuration: ' . $e
      ->getMessage(), $e
      ->getCode(), $e);
  }
  throw new EntityStorageException('Cannot save temporary index configuration: currently being edited by someone else.');
}