You are here

protected function MenuSelection::buildEntityQuery in Menu Admin per Menu 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/MenuSelection.php, line 68

Class

MenuSelection
Provides specific entity reference selection for the menu entity type.

Namespace

Drupal\menu_admin_per_menu\Plugin\EntityReferenceSelection

Code

protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
  $query = parent::buildEntityQuery($match, $match_operator);
  if (!$this->currentUser
    ->hasPermission('administer menu')) {
    $menu_permissions = $this->allowedMenuService
      ->getPerMenuPermissions($this->currentUser);
    $query
      ->condition('id', $menu_permissions, 'IN');
  }
  return $query;
}