You are here

protected function MediaRevisionAccessCheck::countDefaultLanguageRevisions in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/media/src/Access/MediaRevisionAccessCheck.php \Drupal\media\Access\MediaRevisionAccessCheck::countDefaultLanguageRevisions()

Counts the number of revisions in the default language.

Parameters

\Drupal\media\MediaInterface $media: The media item for which to count the revisions.

Return value

int The number of revisions in the default language.

File

core/modules/media/src/Access/MediaRevisionAccessCheck.php, line 133

Class

MediaRevisionAccessCheck
Provides an access checker for media item revisions.

Namespace

Drupal\media\Access

Code

protected function countDefaultLanguageRevisions(MediaInterface $media) {
  $entity_type = $media
    ->getEntityType();
  $count = $this->mediaStorage
    ->getQuery()
    ->accessCheck(FALSE)
    ->allRevisions()
    ->condition($entity_type
    ->getKey('id'), $media
    ->id())
    ->condition($entity_type
    ->getKey('default_langcode'), 1)
    ->count()
    ->execute();
  return $count;
}