trait CachedPaginatedEntityIdListingControllerTrait in Apigee Edge 8
For those controllers that supports paginated entity id listing.
Hierarchy
- trait \Drupal\apigee_edge\Entity\Controller\CachedPaginatedEntityIdListingControllerTrait
See also
\Apigee\Edge\Controller\PaginatedEntityIdListingControllerInterface
1 file declares its use of CachedPaginatedEntityIdListingControllerTrait
- TeamController.php in modules/
apigee_edge_teams/ src/ Entity/ Controller/ TeamController.php
File
- src/
Entity/ Controller/ CachedPaginatedEntityIdListingControllerTrait.php, line 31
Namespace
Drupal\apigee_edge\Entity\ControllerView source
trait CachedPaginatedEntityIdListingControllerTrait {
/**
* The decorated entity controller from the SDK.
*
* We did not added a return type because this way all entity controller's
* decorated() method becomes compatible with this declaration.
*
* @return \Apigee\Edge\Controller\PaginatedEntityIdListingControllerInterface
* An entity controller that extends these interfaces.
*/
protected abstract function decorated();
/**
* Entity id cache used by the entity controller.
*
* @return \Drupal\apigee_edge\Entity\Controller\Cache\EntityIdCacheInterface
* The entity id cache.
*/
protected abstract function entityIdCache() : EntityIdCacheInterface;
/**
* {@inheritdoc}
*/
protected abstract function extractSubsetOfAssociativeArray(array $assoc_array, int $limit, ?string $start_key = NULL) : array;
/**
* {@inheritdoc}
*/
public function getEntityIds(PagerInterface $pager = NULL) : array {
if ($this
->entityIdCache()
->isAllIdsInCache()) {
if ($pager === NULL) {
return $this
->entityIdCache()
->getIds();
}
else {
return $this
->extractSubsetOfAssociativeArray($this
->entityIdCache()
->getIds(), $pager
->getLimit(), $pager
->getStartKey());
}
}
$ids = $this
->decorated()
->getEntityIds($pager);
$this
->entityIdCache()
->saveIds($ids);
if ($pager === NULL) {
$this
->entityIdCache()
->allIdsInCache(TRUE);
}
return $ids;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CachedPaginatedEntityIdListingControllerTrait:: |
abstract protected | function | The decorated entity controller from the SDK. | |
CachedPaginatedEntityIdListingControllerTrait:: |
abstract protected | function | Entity id cache used by the entity controller. | 4 |
CachedPaginatedEntityIdListingControllerTrait:: |
abstract protected | function | ||
CachedPaginatedEntityIdListingControllerTrait:: |
public | function |