public function ApiProductController::delete in Apigee Edge 8
File
- modules/
apigee_edge_apiproduct_rbac/ tests/ modules/ apigee_edge_apiproduct_rbac_test/ src/ ApiProductController.php, line 121
Class
- ApiProductController
- API product controller that reads and writes attributes from/to States API.
Namespace
Drupal\apigee_edge_apiproduct_rbac_testCode
public function delete(string $entity_id) : EntityInterface {
// Because we crated API products on Apigee Edge in create() we also have
// to delete them.
$this->innerService
->delete($entity_id);
$data = $this->state
->get($this
->generateApiProductStateKey($entity_id));
if (NULL === $data) {
throw new ApiException("API Product with {$entity_id} has not found in the storage.");
}
$entity = $this->entitySerializer
->denormalize($data, ApiProduct::class);
$this->state
->delete($this
->generateApiProductStateKey($entity_id));
$list = $this->state
->get(self::STATE_API_PRODUCT_LIST_KEY) ?? [];
if ($index = array_search($entity_id, $list)) {
unset($list[$index]);
}
$this->state
->set(self::STATE_API_PRODUCT_LIST_KEY, $list);
return $entity;
}