You are here

public function ApiProductController::create in Apigee Edge 8

File

modules/apigee_edge_apiproduct_rbac/tests/modules/apigee_edge_apiproduct_rbac_test/src/ApiProductController.php, line 85

Class

ApiProductController
API product controller that reads and writes attributes from/to States API.

Namespace

Drupal\apigee_edge_apiproduct_rbac_test

Code

public function create(EntityInterface $entity) : void {

  // We still have to create entities on Apigee Edge otherwise they can
  // not be assigned to developer apps (unless they gets mocked too).
  $this->innerService
    ->create($entity);

  /** @var \Drupal\apigee_edge\Entity\ApiProductInterface $entity */
  $this->state
    ->set($this
    ->generateApiProductStateKey($entity
    ->id()), $this->entitySerializer
    ->normalize($entity));
  $this
    ->updateAttributes($entity
    ->id(), $entity
    ->getAttributes());
  $list = $this->state
    ->get(self::STATE_API_PRODUCT_LIST_KEY) ?? [];
  $list[] = $entity
    ->id();
  $this->state
    ->set(self::STATE_API_PRODUCT_LIST_KEY, $list);
}