You are here

public function S3FileMap::getFileByUri in Acquia Content Hub 8.2

Returns the file by its uri.

The search is carried out by filtering the main file_managed table using the acquia_contenthub_s3 file map table.

Parameters

string $uri: The uri of the file.

Return value

object|null A matching object with the following fields:

  • file_uuid
  • bucket
  • root_folder
  • origin_uuid

File

modules/acquia_contenthub_s3/src/S3FileMap.php, line 176

Class

S3FileMap
Responsible for storing information about file s3 source.

Namespace

Drupal\acquia_contenthub_s3

Code

public function getFileByUri(string $uri) : ?\stdClass {
  $query = $this->database
    ->select(S3FileMap::TABLE_NAME, 'acs3');
  $query
    ->join('file_managed', 'fm', 'fm.uuid = acs3.file_uuid');
  $object = $query
    ->fields('fm', [
    'uuid',
  ])
    ->fields('acs3', [
    'bucket',
    'root_folder',
    'origin_uuid',
  ])
    ->condition('fm.uri', $uri, '=')
    ->execute()
    ->fetchObject();
  return $object instanceof \stdClass ? $object : NULL;
}