You are here

protected function FileMatcher::buildEntityQuery in Linkit 8.5

Same name and namespace in other branches
  1. 8.4 src/Plugin/Linkit/Matcher/FileMatcher.php \Drupal\linkit\Plugin\Linkit\Matcher\FileMatcher::buildEntityQuery()

Builds an EntityQuery to get entities.

Parameters

string $search_string: Text to match the label against.

Return value

\Drupal\Core\Entity\Query\QueryInterface The EntityQuery object with the basic conditions and sorting applied to it.

Overrides EntityMatcher::buildEntityQuery

File

src/Plugin/Linkit/Matcher/FileMatcher.php, line 165

Class

FileMatcher
Provides specific linkit matchers for the file entity type.

Namespace

Drupal\linkit\Plugin\Linkit\Matcher

Code

protected function buildEntityQuery($search_string) {
  $query = parent::buildEntityQuery($search_string);
  $query
    ->condition('status', $this->configuration['file_status']);
  if (!empty($this->configuration['file_extensions'])) {
    $file_extensions = explode(' ', $this->configuration['file_extensions']);
    $group = $query
      ->orConditionGroup();
    foreach ($file_extensions as $file_extension) {
      $group
        ->condition('filename', '%\\.' . $this->database
        ->escapeLike($file_extension), 'LIKE');
    }
    $query
      ->condition($group);
  }
  return $query;
}