trait CachedPaginatedControllerHelperTrait in Apigee Edge 8
Shared defs. for cached paginated entity & entity od listing controllers.
Hierarchy
- trait \Drupal\apigee_edge\Entity\Controller\CachedPaginatedControllerHelperTrait
1 file declares its use of CachedPaginatedControllerHelperTrait
- TeamController.php in modules/
apigee_edge_teams/ src/ Entity/ Controller/ TeamController.php
File
- src/
Entity/ Controller/ CachedPaginatedControllerHelperTrait.php, line 28
Namespace
Drupal\apigee_edge\Entity\ControllerView source
trait CachedPaginatedControllerHelperTrait {
/**
* 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|\Apigee\Edge\Controller\PaginatedEntityListingControllerInterface
* An entity controller that extends these interfaces.
*/
protected abstract function decorated();
/**
* {@inheritdoc}
*/
public function createPager(int $limit = 0, ?string $start_key = NULL) : PagerInterface {
return $this
->decorated()
->createPager($limit, $start_key);
}
/**
* Utility function that returns a subset of an associative array.
*
* @param array $assoc_array
* Input array.
* @param int $limit
* Limit.
* @param string|null $start_key
* The start key, if it is null than it is first key of the array.
*
* @return array
* Subset of the array.
*/
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);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CachedPaginatedControllerHelperTrait:: |
public | function | ||
CachedPaginatedControllerHelperTrait:: |
abstract protected | function | The decorated entity controller from the SDK. | 1 |
CachedPaginatedControllerHelperTrait:: |
final protected | function | Utility function that returns a subset of an associative array. |