You are here

public function FileEntityItem::query in Media Migration 8

Return value

\Drupal\Core\Database\Query\SelectInterface

Overrides SqlBase::query

File

src/Plugin/migrate/source/d7/FileEntityItem.php, line 81

Class

FileEntityItem
File Entity Item source plugin.

Namespace

Drupal\media_migration\Plugin\migrate\source\d7

Code

public function query() {
  [
    'type' => $type,
    'scheme' => $scheme,
  ] = $this->configuration;
  if ($scheme && ($pos = strpos($scheme, '://')) !== FALSE) {
    $scheme = substr($scheme, 0, $pos);
  }
  $query = $this
    ->getFileEntityBaseQuery(NULL, FALSE)
    ->fields('fm')
    ->orderBy('fm.timestamp');

  // Filter by type, if configured.
  if ($type) {
    $query
      ->condition('fm.type', $type);
  }

  // Filter by URI prefix if specified.
  if ($scheme) {
    $query
      ->where("{$this->getSchemeExpression()} = :scheme", [
      ':scheme' => $scheme,
    ]);
  }
  return $query;
}