You are here

final protected function CachedPaginatedControllerHelperTrait::extractSubsetOfAssociativeArray in Apigee Edge 8

Utility function that returns a subset of an associative array.

Parameters

array $assoc_array: Input array.

int $limit: Limit.

string|null $start_key: The start key, if it is null than it is first key of the array.

Return value

array Subset of the array.

3 calls to CachedPaginatedControllerHelperTrait::extractSubsetOfAssociativeArray()
AppController::getAppsFromCacheByStatus in src/Entity/Controller/AppController.php
Returns apps from the cache by status.
AppController::listAppIds in src/Entity/Controller/AppController.php
AppController::listApps in src/Entity/Controller/AppController.php

File

src/Entity/Controller/CachedPaginatedControllerHelperTrait.php, line 61

Class

CachedPaginatedControllerHelperTrait
Shared defs. for cached paginated entity & entity od listing controllers.

Namespace

Drupal\apigee_edge\Entity\Controller

Code

protected final function extractSubsetOfAssociativeArray(array $assoc_array, int $limit, ?string $start_key = NULL) : array {
  $array_keys = array_keys($assoc_array);
  if ($start_key === NULL) {
    $start_key = reset($array_keys);
  }
  $pos = array_search($start_key, $array_keys);
  return array_slice($assoc_array, $pos, $limit);
}