You are here

public function FilesExtractor::limitToAllowedNumber in Search API attachments 9.0.x

Same name and namespace in other branches
  1. 8 src/Plugin/search_api/processor/FilesExtractor.php \Drupal\search_api_attachments\Plugin\search_api\processor\FilesExtractor::limitToAllowedNumber()

Limit the number of items to index per field to the configured limit.

Parameters

array $all_fids: Array of fids.

Return value

array An array of $limit number of items.

1 call to FilesExtractor::limitToAllowedNumber()
FilesExtractor::addFieldValues in src/Plugin/search_api/processor/FilesExtractor.php

File

src/Plugin/search_api/processor/FilesExtractor.php, line 373

Class

FilesExtractor
Provides file fields processor.

Namespace

Drupal\search_api_attachments\Plugin\search_api\processor

Code

public function limitToAllowedNumber(array $all_fids) {
  $limit = 0;
  if (isset($this->configuration['number_indexed'])) {
    $limit = $this->configuration['number_indexed'];
  }

  // If limit is 0 return all items.
  if ($limit == 0) {
    return $all_fids;
  }
  if (count($all_fids) > $limit) {
    return array_slice($all_fids, 0, $limit);
  }
  else {
    return $all_fids;
  }
}