includeCount example

// Drop the last result.       array_pop($results);
    }
    // Each item of the collection data contains an array with 'entity' and     // 'access' elements.     $collection_data = $this->loadEntitiesWithAccess($storage$results$request->get(ResourceVersionRouteEnhancer::WORKING_COPIES_REQUESTED, FALSE));
    $primary_data = new ResourceObjectData($collection_data);
    $primary_data->setHasNextPage($has_next_page);

    // Calculate all the results and pass into a JSON:API Data object.     $count_query_cacheability = new CacheableMetadata();
    if ($resource_type->includeCount()) {
      $count_query = $this->getCollectionCountQuery($resource_type$params$count_query_cacheability);
      $total_results = $this->executeQueryInRenderContext(
        $count_query,
        $count_query_cacheability
      );

      $primary_data->setTotalCount($total_results);
    }

    $response = $this->respondWithCollection($primary_data$this->getIncludes($request$primary_data)$request$resource_type$params[OffsetPage::KEY_NAME]);

    
Home | Imprint | This part of the site doesn't use cookies.