public function MappingListBuilder::load in GatherContent 8.5
Same name and namespace in other branches
- 8.4 gathercontent_ui/src/MappingListBuilder.php \Drupal\gathercontent_ui\MappingListBuilder::load()
Loads entities of this type from storage for listing.
This allows the implementation to manipulate the listing, like filtering or sorting the loaded entities.
Return value
\Drupal\Core\Entity\EntityInterface[] An array of entities implementing \Drupal\Core\Entity\EntityInterface indexed by their IDs. Returns an empty array if no matching entities are found.
Overrides ConfigEntityListBuilder::load
File
- gathercontent_ui/
src/ MappingListBuilder.php, line 83
Class
- MappingListBuilder
- Provides a listing of GatherContent Mapping entities.
Namespace
Drupal\gathercontent_uiCode
public function load() {
$entity_query = $this->entityTypeManager
->getStorage('gathercontent_mapping')
->getQuery();
$query_string = $this->request->query;
$headers = $this
->buildHeader();
$entity_query
->pager(100);
if ($query_string
->has('order')) {
foreach ($headers as $header) {
if (is_array($header) && $header['data'] === $query_string
->get('order')) {
$sort = 'ASC';
if ($query_string
->has('sort') && $query_string
->get('sort') === 'asc' || $query_string
->get('sort') === 'desc') {
$sort = mb_strtoupper($query_string
->get('sort'));
}
$entity_query
->sort($header['field'], $sort);
}
}
}
$entity_query
->tableSort($headers);
$entity_ids = $entity_query
->execute();
return $this->storage
->loadMultiple($entity_ids);
}