You are here

protected function LayoutLibrary::buildEntityQuery in Layout builder library 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

File

src/Plugin/EntityReferenceSelection/LayoutLibrary.php, line 24

Class

LayoutLibrary
Filters reference-able layouts according to target entity type and bundle.

Namespace

Drupal\layout_library\Plugin\EntityReferenceSelection

Code

protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
  $query = parent::buildEntityQuery($match, $match_operator);
  $configuration = $this
    ->getConfiguration();
  if ($configuration['entity'] instanceof EntityInterface) {
    $query
      ->condition('targetEntityType', $configuration['entity']
      ->getEntityTypeId())
      ->condition('targetBundle', $configuration['entity']
      ->bundle());
  }
  return $query;
}