]> git.mxchange.org Git - friendica-addons.git/blob - s3_storage/s3_storage.php
Merge pull request 'CLD2: Use ISO-639-1 for the language detection' (#1433) from...
[friendica-addons.git] / s3_storage / s3_storage.php
1 <?php
2 /*
3  * Name: S3 Storage
4  * Description: Adds the possibility to use Amazon S3 as a selectable storage backend
5  * Version: 1.0
6  * Author: Philipp Holzer
7  */
8
9 use Friendica\Addon\s3_storage\src\S3Client;
10 use Friendica\Addon\s3_storage\src\S3Config;
11 use Friendica\App;
12 use Friendica\Core\Hook;
13 use Friendica\DI;
14
15 require_once __DIR__ . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php';
16
17 function s3_storage_install()
18 {
19         Hook::register('storage_instance' , __FILE__, 's3_storage_instance');
20         Hook::register('storage_config' , __FILE__, 's3_storage_config');
21         DI::storageManager()->register(S3Client::class);
22 }
23
24 function s3_storage_uninstall()
25 {
26         DI::storageManager()->unregister(S3Client::class);
27 }
28
29 function s3_storage_instance(array &$data)
30 {
31         if ($data['name'] == S3Client::getName()) {
32                 $config          = new S3Config(DI::l10n(), DI::config());
33                 $data['storage'] = new S3Client($config->getConfig(), $config->getBucket());
34         }
35 }
36
37 function s3_storage_config(array &$data)
38 {
39         if ($data['name'] == S3Client::getName()) {
40                 $data['storage_config'] = new S3Config(DI::l10n(), DI::config());
41         }
42 }