You are here

protected function EntityQuery::applyRevisionsMode in GraphQL 8.3

Apply the specified revision filtering mode to the query.

Parameters

\Drupal\Core\Entity\Query\QueryInterface $query: The entity query object.

mixed $mode: The revision query mode.

Return value

\Drupal\Core\Entity\Query\QueryInterface The entity query object.

2 calls to EntityQuery::applyRevisionsMode()
EntityQuery::getQuery in modules/graphql_core/src/Plugin/GraphQL/Fields/EntityQuery/EntityQuery.php
Create the full entity query for the plugin's entity type.
EntityRevisions::getBaseQuery in modules/graphql_core/src/Plugin/GraphQL/Fields/Entity/EntityRevisions.php
Create the basic entity query for the plugin's entity type.

File

modules/graphql_core/src/Plugin/GraphQL/Fields/EntityQuery/EntityQuery.php, line 232

Class

EntityQuery
@GraphQLField( id = "entity_query", secure = false, type = "EntityQueryResult", arguments = { "filter" = "EntityQueryFilterInput", "sort" = "[EntityQuerySortInput]", "offset" =…

Namespace

Drupal\graphql_core\Plugin\GraphQL\Fields\EntityQuery

Code

protected function applyRevisionsMode(QueryInterface $query, $mode) {
  if ($mode === 'all') {

    // Mark the query as such and sort by the revision id too.
    $query
      ->allRevisions();
    $query
      ->addTag('revisions');
  }
  else {
    if ($mode === 'latest') {

      // Mark the query to only include latest revision and sort by revision id.
      $query
        ->latestRevision();
      $query
        ->addTag('revisions');
    }
  }
  return $query;
}