You are here

public function ApiProductController::getEntities in Apigee Edge 8

File

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

Class

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

Namespace

Drupal\apigee_edge_apiproduct_rbac_test

Code

public function getEntities(PagerInterface $pager = NULL, string $key_provider = 'id') : array {

  /** @var \Drupal\apigee_edge\Entity\ApiProductInterface $entity */
  $ids = array_map(function ($id) {
    return $this
      ->generateApiProductStateKey($id);
  }, $this->state
    ->get(self::STATE_API_PRODUCT_LIST_KEY) ?? []);
  $entities = [];
  foreach ($this->state
    ->getMultiple($ids) as $data) {
    $entity = $this->entitySerializer
      ->denormalize($data, ApiProduct::class);
    $this
      ->setAttributesFromStates($entity);
    $entities[$entity
      ->id()] = $entity;
  }
  return $entities;
}