You are here

protected function EdgeEntityStorageBase::doSave in Apigee Edge 8

Performs storage-specific saving of the entity.

Parameters

int|string $id: The original entity ID.

\Drupal\Core\Entity\EntityInterface $entity: The entity to save.

Return value

bool|int If the record insert or update failed, returns FALSE. If it succeeded, returns SAVED_NEW or SAVED_UPDATED, depending on the operation performed.

Overrides EntityStorageBase::doSave

2 calls to EdgeEntityStorageBase::doSave()
DeveloperStorage::doSave in src/Entity/Storage/DeveloperStorage.php
Performs storage-specific saving of the entity.
TeamStorage::doSave in modules/apigee_edge_teams/src/Entity/Storage/TeamStorage.php
Performs storage-specific saving of the entity.
2 methods override EdgeEntityStorageBase::doSave()
DeveloperStorage::doSave in src/Entity/Storage/DeveloperStorage.php
Performs storage-specific saving of the entity.
TeamStorage::doSave in modules/apigee_edge_teams/src/Entity/Storage/TeamStorage.php
Performs storage-specific saving of the entity.

File

src/Entity/Storage/EdgeEntityStorageBase.php, line 160

Class

EdgeEntityStorageBase
Base entity storage class for Apigee Edge entities.

Namespace

Drupal\apigee_edge\Entity\Storage

Code

protected function doSave($id, EntityInterface $entity) {
  $result = static::SAVED_UNKNOWN;
  $this
    ->withController(function (EdgeEntityControllerInterface $controller) use ($id, $entity, &$result) {

    /** @var \Drupal\apigee_edge\Entity\EdgeEntityInterface $entity */
    if ($entity
      ->isNew()) {
      $controller
        ->create($entity
        ->decorated());
      $result = SAVED_NEW;
    }
    else {
      $controller
        ->update($entity
        ->decorated());
      $result = SAVED_UPDATED;
    }
  });
  return $result;
}