You are here

protected function BatchWatermarkForm::getFiles in Media watermark 8

Helper to get image files.

Parameters

array $headers: Table sort headers array.

Return value

array List of file identifiers.

1 call to BatchWatermarkForm::getFiles()
BatchWatermarkForm::getImageFiles in src/Form/BatchWatermarkForm.php
Get files sortable table.

File

src/Form/BatchWatermarkForm.php, line 367

Class

BatchWatermarkForm
Class BatchWatermarkForm.

Namespace

Drupal\media_watermark\Form

Code

protected function getFiles(array $headers) {
  $query = \Drupal::entityQuery('file');
  $query
    ->tableSort($headers);

  // Load only image files.
  $query
    ->condition('filemime', 'image/%', 'LIKE');
  $query
    ->pager(50);

  // Add condition to hide watermarks on batch add page.
  if (!empty($this->watermarksFids)) {
    $query
      ->condition('fid', $this->watermarksFids, 'NOT IN');
  }

  // TODO: prevent direct usage of $_GET.
  if (!empty($_GET['search'])) {
    $query
      ->condition('filename', $_GET['search'] . '%', 'LIKE');
  }
  $fids = $query
    ->execute();
  return $fids;
}