You are here

public function DataProviderEntity::getIndexIds in RESTful 7.2

Returns the ID to render for the current index GET request.

Return value

array Numeric array containing the identifiers to be sent to viewMultiple.

Overrides DataProviderInterface::getIndexIds

File

src/Plugin/resource/DataProvider/DataProviderEntity.php, line 161
Contains \Drupal\restful\Plugin\resource\DataProvider\DataProviderEntity.

Class

DataProviderEntity
Class DataProviderEntity.

Namespace

Drupal\restful\Plugin\resource\DataProvider

Code

public function getIndexIds() {
  $result = $this
    ->getQueryForList()
    ->execute();
  if (empty($result[$this->entityType])) {
    return array();
  }
  $entity_ids = array_keys($result[$this->entityType]);
  if (empty($this->options['idField'])) {
    return $entity_ids;
  }

  // Get the list of IDs.
  $resource_field = $this->fieldDefinitions
    ->get($this->options['idField']);
  $ids = array();
  foreach ($entity_ids as $entity_id) {
    $interpreter = new DataInterpreterEMW($this
      ->getAccount(), new \EntityDrupalWrapper($this->entityType, $entity_id));
    $ids[] = $resource_field
      ->value($interpreter);
  }
  return $ids;
}