You are here

public function BynderService::getTotalCountOfMediaEntities in Bynder 4.0.x

Same name and namespace in other branches
  1. 8.3 src/BynderService.php \Drupal\bynder\BynderService::getTotalCountOfMediaEntities()
  2. 8.2 src/BynderService.php \Drupal\bynder\BynderService::getTotalCountOfMediaEntities()

Returns the total number of Bynder media entities.

Return value

int A total number of Bynder media entities.

Overrides BynderServiceInterface::getTotalCountOfMediaEntities

File

src/BynderService.php, line 139

Class

BynderService
Bynder service.

Namespace

Drupal\bynder

Code

public function getTotalCountOfMediaEntities() {
  $bynder_media_types = $this
    ->getBynderMediaTypes();
  if (empty($bynder_media_types)) {
    return 0;
  }
  $count = $this->mediaStorage
    ->getQuery()
    ->accessCheck(FALSE)
    ->condition($this->mediaStorage
    ->getEntityType()
    ->getKey('bundle'), array_keys($bynder_media_types), 'IN')
    ->count()
    ->execute();
  return (int) $count;
}