You are here

public function WorkspacePointerSelection::buildEntityQuery in Workspace 8

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

1 call to WorkspacePointerSelection::buildEntityQuery()
WorkspacePointerSelection::getReferenceableEntities in src/Plugin/EntityReferenceSelection/WorkspacePointerSelection.php
Gets the list of referenceable entities.

File

src/Plugin/EntityReferenceSelection/WorkspacePointerSelection.php, line 25

Class

WorkspacePointerSelection
Provides specific access control for the node entity type.

Namespace

Drupal\workspace\Plugin\EntityReferenceSelection

Code

public function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
  $query = parent::buildEntityQuery($match, $match_operator);
  if (isset($this
    ->getConfiguration()['entity']) && $this
    ->getConfiguration()['entity'] instanceof WorkspaceInterface && !$this
    ->getConfiguration()['entity']
    ->isNew()) {
    $group = $query
      ->orConditionGroup()
      ->condition('workspace_pointer', $this
      ->getConfiguration()['entity']
      ->id(), '<>')
      ->notExists('workspace_pointer');
    $query
      ->condition($group);
  }
  return $query;
}