public function Exporter::updateFileGcIds in GatherContent 8.5
Updates the file managed table to include the new GC ID for a given file.
Parameters
array $returnedAssets: The assets returned by GC.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Core\Entity\EntityStorageException
1 call to Exporter::updateFileGcIds()
- Exporter::export in gathercontent_upload/
src/ Export/ Exporter.php  - Exports the changes made in Drupal contents.
 
File
- gathercontent_upload/
src/ Export/ Exporter.php, line 693  
Class
- Exporter
 - Class for handling import/update logic from GatherContent to Drupal.
 
Namespace
Drupal\gathercontent_upload\ExportCode
public function updateFileGcIds(array $returnedAssets) {
  if (empty($this->collectedFileFields) || empty($returnedAssets)) {
    return;
  }
  foreach ($this->collectedFileFields as $fieldUuid => $fileField) {
    if (empty($returnedAssets[$fieldUuid])) {
      continue;
    }
    foreach ($fileField as $delta => $target) {
      /** @var \Drupal\file\FileInterface $file */
      $file = $this->entityTypeManager
        ->getStorage('file')
        ->load($target['target_id']);
      if (empty($file) || empty($returnedAssets[$fieldUuid][$delta])) {
        continue;
      }
      $file
        ->set('gc_file_id', $returnedAssets[$fieldUuid][$delta]);
      $file
        ->save();
    }
  }
}