You are here

private function AppController::getAppsFromCacheByStatus in Apigee Edge 8

Returns apps from the cache by status.

Parameters

string $status: App status.

\Apigee\Edge\Structure\PagerInterface|null $pager: Pager.

Return value

array|null If not all apps in the cache it returns null, otherwise it returns the required amount of apps from the cache.

2 calls to AppController::getAppsFromCacheByStatus()
AppController::listAppIdsByStatus in src/Entity/Controller/AppController.php
AppController::listAppsByStatus in src/Entity/Controller/AppController.php

File

src/Entity/Controller/AppController.php, line 222

Class

AppController
Definition of the App controller service.

Namespace

Drupal\apigee_edge\Entity\Controller

Code

private function getAppsFromCacheByStatus(string $status, PagerInterface $pager = NULL) : ?array {
  $apps = NULL;
  if ($this->appCache
    ->isAllEntitiesInCache()) {
    if ($pager === NULL) {
      $apps = $this->appCache
        ->getEntities();
    }
    else {
      $apps = $this
        ->extractSubsetOfAssociativeArray($this->appCache
        ->getEntities(), $pager
        ->getLimit(), $pager
        ->getStartKey());
    }
    $apps = array_filter($apps, function (AppInterface $app) use ($status) {
      return $app
        ->getStatus() === $status;
    });
  }
  return $apps;
}