You are here

protected function GroupMenuContentListBuilder::getEntityIds in Group Menu 8

Loads entity IDs using a pager sorted by the entity id.

Return value

array An array of entity IDs.

Overrides GroupContentListBuilder::getEntityIds

File

src/GroupMenuContentListBuilder.php, line 17

Class

GroupMenuContentListBuilder
Provides a list controller for menus entities in a group.

Namespace

Drupal\groupmenu

Code

protected function getEntityIds() {
  $plugin_id = 'group_menu:menu';
  $group_content_types = GroupContentType::loadByContentPluginId($plugin_id);

  // If we don't have any group menu plugins, we don't have any group menu's.
  if (empty($group_content_types)) {
    return [];
  }
  $query = $this
    ->getStorage()
    ->getQuery();

  // Filter by group menu plugins.
  $query
    ->condition('type', array_keys($group_content_types), 'IN');

  // Only show group content for the group on the route.
  $query
    ->condition('gid', $this->group
    ->id());

  // Only add the pager if a limit is specified.
  if ($this->limit) {
    $query
      ->pager($this->limit);
  }
  $query
    ->sort($this->entityType
    ->getKey('id'));
  return $query
    ->execute();
}