protected function TeamStorage::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
- modules/
apigee_edge_teams/ src/ Entity/ Storage/ TeamStorage.php, line 125
Class
- TeamStorage
- Entity storage implementation for teams.
Namespace
Drupal\apigee_edge_teams\Entity\StorageCode
protected function doSave($id, EntityInterface $entity) {
/** @var \Drupal\apigee_edge_teams\Entity\TeamInterface $entity */
$team_status = $entity
->getStatus();
$result = parent::doSave($id, $entity);
// Change the status of the team (company) in Apigee Edge.
// TODO Only change it if it has changed.
try {
$this->teamController
->setStatus($entity
->id(), $team_status);
} catch (ApiException $exception) {
throw new EntityStorageException($exception
->getMessage(), $exception
->getCode(), $exception);
}
// Apply status change in the entity object as well.
$entity
->setStatus($team_status);
return $result;
}