function AllExceptHostEntity::buildEntityQuery
Builds an EntityQuery to get referenceable entities.
Parameters
string|null $match: (Optional) Text to match the label against. Defaults to NULL.
string $match_operator: (Optional) The operation the matching should be done with. Defaults to "CONTAINS".
Return value
\Drupal\Core\Entity\Query\QueryInterface The EntityQuery object with the basic conditions and sorting applied to it.
Overrides DefaultSelection::buildEntityQuery
File
- 
              core/
modules/ system/ tests/ modules/ entity_reference_test/ src/ Plugin/ EntityReferenceSelection/ AllExceptHostEntity.php, line 23  
Class
- AllExceptHostEntity
 - Allows access to all entities except for the host entity.
 
Namespace
Drupal\entity_reference_test\Plugin\EntityReferenceSelectionCode
protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
  $query = parent::buildEntityQuery($match, $match_operator);
  /** @var \Drupal\Core\Entity\EntityInterface $entity */
  if ($entity = $this->configuration['entity']) {
    $target_type = $this->configuration['target_type'];
    $entity_type = $this->entityTypeManager
      ->getDefinition($target_type);
    $query->condition($entity_type->getKey('id'), $entity->id(), '<>');
  }
  return $query;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.