You are here

public static function RefreshBatch::count in Media Thumbnails 8

Returns the total number of media entities.

Return value

int The number of media entities.

2 calls to RefreshBatch::count()
MediaThumbnailRefreshForm::getDescription in src/Form/MediaThumbnailRefreshForm.php
Returns additional text to display as a description.
RefreshBatch::process in src/Batch/RefreshBatch.php
Batch process callback.

File

src/Batch/RefreshBatch.php, line 43

Class

RefreshBatch
Class RefreshBatch.

Namespace

Drupal\media_thumbnails\Batch

Code

public static function count() : int {

  /** @var \Drupal\Core\Entity\EntityTypeManager $entity_type_manager */
  $entity_type_manager = Drupal::service('entity_type.manager');
  try {
    $storage = $entity_type_manager
      ->getStorage('media');
  } catch (Exception $e) {
    return 0;
  }
  $query = $storage
    ->getAggregateQuery();
  $query
    ->count();
  return (int) $query
    ->execute();
}