protected function DeveloperStorage::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 EdgeEntityStorageBase::doSave
File
- src/
Entity/ Storage/ DeveloperStorage.php, line 148
Class
- DeveloperStorage
- Entity storage implementation for developers.
Namespace
Drupal\apigee_edge\Entity\StorageCode
protected function doSave($id, EntityInterface $entity) {
/** @var \Drupal\apigee_edge\Entity\DeveloperInterface $entity */
$developer_status = $entity
->getStatus();
$result = parent::doSave($id, $entity);
// In case of entity update, the original email must be
// cleared before a new API call.
if ($result === SAVED_UPDATED) {
$entity
->resetOriginalEmail();
}
// Change the status of the developer in Apigee Edge.
// TODO Only change it if it has changed.
try {
$this->developerController
->setStatus($entity
->id(), $developer_status);
} catch (ApiException $exception) {
throw new EntityStorageException($exception
->getMessage(), $exception
->getCode(), $exception);
}
// Apply status change in the entity object as well.
$entity
->setStatus($developer_status);
return $result;
}