function acquia_contenthub_s3_install in Acquia Content Hub 8.2
Implements hook_install().
File
- modules/
acquia_contenthub_s3/ acquia_contenthub_s3.install, line 24 - Acquia Content Hub S3 integration.
Code
function acquia_contenthub_s3_install() {
$database = \Drupal::database();
$files = $database
->select('file_managed', 'fm')
->fields('fm', [
'uuid',
])
->condition('fm.uri', 's3://%', 'LIKE')
->execute()
->fetchAll(PDO::FETCH_ASSOC);
$file_map = \Drupal::getContainer()
->get('acquia_contenthub_s3.file_map');
$config_factory = \Drupal::configFactory();
$s3fs_config = $config_factory
->get('s3fs.settings');
$ch_config = $config_factory
->get('acquia_contenthub.admin_settings');
foreach ($files as $file) {
$file_map
->record($file['uuid'], $s3fs_config
->get('bucket'), $s3fs_config
->get('root_folder'), $ch_config
->get('origin'));
}
}