You are here

public function S3FileMap::record in Acquia Content Hub 8.2

Records the origin of an s3 file.

Updates the tracked file if it exists.

Parameters

string $file_uuid: The file entity uuid.

string $bucket: The source bucket name.

string $root_folder: The source of the file. This is preferably the root_folder of the publisher site.

string $origin_uuid: The publisher site's origin uuid.

Throws

\Exception

File

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

Class

S3FileMap
Responsible for storing information about file s3 source.

Namespace

Drupal\acquia_contenthub_s3

Code

public function record(string $file_uuid, string $bucket, string $root_folder, string $origin_uuid) : void {
  foreach ([
    'file_uuid',
    'origin_uuid',
  ] as $uuid) {
    if (!Uuid::isValid(strtolower(${$uuid}))) {
      throw new \InvalidArgumentException("The provided uuid for {$uuid} is invalid: {${$uuid}}");
    }
  }
  $this
    ->isNew($file_uuid) ? $this
    ->insert($file_uuid, $bucket, $root_folder, $origin_uuid) : $this
    ->update($file_uuid, [
    'bucket' => $bucket,
    'root_folder' => $root_folder,
    'origin_uuid' => $origin_uuid,
  ]);
}