You are here

protected function EntityRevisionRouteAccessChecker::countDefaultLanguageRevisions in Entity API 8.0

Same name and namespace in other branches
  1. 8 src/Access/EntityRevisionRouteAccessChecker.php \Drupal\entity\Access\EntityRevisionRouteAccessChecker::countDefaultLanguageRevisions()

Counts the number of revisions in the default language.

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity.

\Drupal\Core\Entity\EntityStorageInterface $entity_storage: The entity storage.

Return value

int The number of revisions in the default language.

File

src/Access/EntityRevisionRouteAccessChecker.php, line 128
Contains \Drupal\entity\Access\EntityRevisionRouteAccessChecker

Class

EntityRevisionRouteAccessChecker
Checks access to a entity revision.

Namespace

Drupal\entity\Access

Code

protected function countDefaultLanguageRevisions(ContentEntityInterface $entity, EntityStorageInterface $entity_storage) {
  $entity_type = $entity
    ->getEntityType();
  $count = $entity_storage
    ->getQuery()
    ->allRevisions()
    ->condition($entity_type
    ->getKey('id'), $entity
    ->id())
    ->condition($entity_type
    ->getKey('default_langcode'), 1)
    ->count()
    ->execute();
  return $count;
}