Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. FileSelection.php

function FileSelection::buildEntityQuery

Overrides DefaultSelection::buildEntityQuery

File

core/modules/file/src/Plugin/EntityReferenceSelection/FileSelection.php, line 25

Class

FileSelection
Provides specific access control for the file entity type.

Namespace

Drupal\file\Plugin\EntityReferenceSelection

Code

protected function buildEntityQuery($match = NULL, $match_operator = 'CONTAINS') {
    $query = parent::buildEntityQuery($match, $match_operator);
    // Allow referencing :
    // - files with status "permanent"
    // - or files uploaded by the current user (since newly uploaded files only
    //   become "permanent" after the containing entity gets validated and
    //   saved.)
    $query->condition($query->orConditionGroup()
        ->condition('status', FileInterface::STATUS_PERMANENT)
        ->condition('uid', $this->currentUser
        ->id()));
    return $query;
}

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal