public function AppController::listApps in Apigee Edge 8
File
- src/
Entity/ Controller/ AppController.php, line 133
Class
- AppController
- Definition of the App controller service.
Namespace
Drupal\apigee_edge\Entity\ControllerCode
public function listApps(bool $include_credentials = FALSE, PagerInterface $pager = NULL) : array {
// If all entities in the cache and apps with credentials should be
// returned.
if ($this->appCache
->isAllEntitiesInCache() && $include_credentials === TRUE) {
if ($pager === NULL) {
return $this->appCache
->getEntities();
}
else {
return $this
->extractSubsetOfAssociativeArray($this->appCache
->getEntities(), $pager
->getLimit(), $pager
->getStartKey());
}
}
$result = $this
->decorated()
->listApps($include_credentials, $pager);
// We only cache "complete" apps, we do not cache apps without credentials.
if ($include_credentials) {
$this->appCache
->saveEntities($result);
// Null pager means the PHP API client has loaded all apps from
// Apigee Edge.
if ($pager === NULL) {
$this->appCache
->allEntitiesInCache(TRUE);
$apps_by_owner = [];
foreach ($result as $app) {
$apps_by_owner[$this->appCache
->getAppOwner($app)][$app
->getAppId()] = $app;
}
foreach ($apps_by_owner as $owner => $apps) {
$apps_by_owner_cache = $this->appByOwnerAppCacheFactory
->getAppCache($owner);
$apps_by_owner_cache
->saveEntities($apps);
$apps_by_owner_cache
->allEntitiesInCache(TRUE);
}
}
}
else {
// Little trick here, even if we have not loaded complete app objects
// we can still cache their ids.
$this->appIdCache
->saveEntities($result);
// Moreover we can mark the app id cache as completed if pager is null.
if ($pager === NULL) {
$this->appIdCache
->allIdsInCache(TRUE);
}
}
return $result;
}