You are here

protected function NodeMatcher::buildEntityQuery in Linkit 8.4

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

Builds an EntityQuery to get entities.

Parameters

$match: 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/NodeMatcher.php, line 81
Contains \Drupal\linkit\Plugin\Linkit\Matcher\NodeMatcher.

Class

NodeMatcher
Plugin annotation @Matcher( id = "entity:node", target_entity = "node", label = @Translation("Content"), provider = "node" )

Namespace

Drupal\linkit\Plugin\Linkit\Matcher

Code

protected function buildEntityQuery($match) {
  $query = parent::buildEntityQuery($match);
  $no_access = !$this->currentUser
    ->hasPermission('bypass node access') && !count($this->moduleHandler
    ->getImplementations('node_grants'));
  if ($this->configuration['include_unpublished'] !== TRUE || $no_access) {
    $query
      ->condition('status', NODE_PUBLISHED);
  }
  return $query;
}