function MediaSelection::buildEntityQuery

Same name in other branches
  1. 9 core/modules/media/src/Plugin/EntityReferenceSelection/MediaSelection.php \Drupal\media\Plugin\EntityReferenceSelection\MediaSelection::buildEntityQuery()
  2. 8.9.x core/modules/media/src/Plugin/EntityReferenceSelection/MediaSelection.php \Drupal\media\Plugin\EntityReferenceSelection\MediaSelection::buildEntityQuery()
  3. 10 core/modules/media/src/Plugin/EntityReferenceSelection/MediaSelection.php \Drupal\media\Plugin\EntityReferenceSelection\MediaSelection::buildEntityQuery()

Overrides DefaultSelection::buildEntityQuery

File

core/modules/media/src/Plugin/EntityReferenceSelection/MediaSelection.php, line 24

Class

MediaSelection
Provides specific access control for the media entity type.

Namespace

Drupal\media\Plugin\EntityReferenceSelection

Code

protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
    $query = parent::buildEntityQuery($match, $match_operator);
    // Ensure that users with insufficient permission cannot see unpublished
    // entities.
    if (!$this->currentUser
        ->hasPermission('administer media')) {
        $query->condition('status', 1);
    }
    return $query;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.