You are here

public function RestfulDataProviderDbQuery::getQueryCount in RESTful 7

Prepare a query for RestfulEntityBase::getTotalCount().

Return value

\SelectQuery The query object.

Throws

RestfulBadRequestException

Overrides RestfulDataProviderDbQueryInterface::getQueryCount

File

plugins/restful/RestfulDataProviderDbQuery.php, line 277
Contains \RestfulDataProviderDbQuery

Class

RestfulDataProviderDbQuery
@file Contains \RestfulDataProviderDbQuery

Code

public function getQueryCount() {
  $table = $this
    ->getTableName();
  $query = $this
    ->getQuery();
  if ($path = $this
    ->getPath()) {
    $ids = explode(',', $path);
    if (!empty($ids)) {
      foreach ($this
        ->getIdColumn() as $index => $column) {
        $query
          ->condition($table . '.' . $column, $this
          ->getColumnFromIds($ids, $index), 'IN');
      }
    }
  }
  $this
    ->queryForListFilter($query);
  $this
    ->addExtraInfoToQuery($query);
  $query
    ->addTag('restful_count');
  return $query
    ->countQuery();
}