You are here

public function S3FileMapper::mapS3File in Acquia Content Hub 8.2

Maps the file entity and its s3 source.

Parameters

\Acquia\ContentHubClient\CDF\CDFObject $cdf: The cdf representation of the file entity.

\Drupal\file\FileInterface $file: The file entity to map to.

Throws

\Exception

File

modules/acquia_contenthub_s3/src/S3FileMapper.php, line 79

Class

S3FileMapper
S3FileMapper for tracking S3 files.

Namespace

Drupal\acquia_contenthub_s3

Code

public function mapS3File(CDFObject $cdf, FileInterface $file) : void {
  $root_folder = $cdf
    ->getAttribute('ach_s3_source');
  $bucket = $cdf
    ->getAttribute('ach_s3_bucket');
  if (!$root_folder || !$bucket) {
    return;
  }
  $root_folder = $root_folder
    ->getValue()[LanguageInterface::LANGCODE_NOT_SPECIFIED];
  $bucket = $bucket
    ->getValue()[LanguageInterface::LANGCODE_NOT_SPECIFIED];
  $uuid = $file
    ->uuid();
  $this->s3FileMap
    ->record($uuid, $bucket, $root_folder, $cdf
    ->getOrigin());
  if (!$this->s3FileMap
    ->isNew($uuid)) {
    $this
      ->invalidateFileCache($file);
  }
}