2021-08-25 23:47:18 +02:00
|
|
|
<?php
|
|
|
|
/*
|
|
|
|
* Name: WebDAV Storage
|
|
|
|
* Description: Adds the possibility to use WebDAV as a selectable storage backend
|
|
|
|
* Version: 1.0
|
|
|
|
* Author: Philipp Holzer
|
|
|
|
*/
|
|
|
|
|
|
|
|
use Friendica\Addon\webdav_storage\src\WebDav;
|
2021-10-04 11:40:05 +02:00
|
|
|
use Friendica\Addon\webdav_storage\src\WebDavConfig;
|
2021-08-25 23:47:18 +02:00
|
|
|
use Friendica\Core\Hook;
|
|
|
|
use Friendica\DI;
|
|
|
|
|
2024-11-23 09:32:43 +01:00
|
|
|
function webdav_storage_install()
|
2021-08-25 23:47:18 +02:00
|
|
|
{
|
|
|
|
Hook::register('storage_instance' , __FILE__, 'webdav_storage_instance');
|
2021-10-04 11:40:05 +02:00
|
|
|
Hook::register('storage_config' , __FILE__, 'webdav_storage_config');
|
2021-08-25 23:47:18 +02:00
|
|
|
DI::storageManager()->register(WebDav::class);
|
|
|
|
}
|
|
|
|
|
|
|
|
function webdav_storage_uninstall()
|
|
|
|
{
|
2021-10-04 11:40:05 +02:00
|
|
|
DI::storageManager()->unregister(WebDav::class);
|
2021-08-25 23:47:18 +02:00
|
|
|
}
|
|
|
|
|
2023-01-14 03:16:09 +01:00
|
|
|
function webdav_storage_instance(array &$data)
|
2021-08-25 23:47:18 +02:00
|
|
|
{
|
2022-01-07 02:14:24 +01:00
|
|
|
if ($data['name'] == WebDav::getName()) {
|
|
|
|
$config = new WebDavConfig(DI::l10n(), DI::config(), DI::httpClient());
|
|
|
|
$data['storage'] = new WebDav($config->getUrl(), $config->getAuthOptions(), DI::httpClient(), DI::logger());
|
|
|
|
}
|
2021-10-04 11:40:05 +02:00
|
|
|
}
|
|
|
|
|
2023-01-14 03:16:09 +01:00
|
|
|
function webdav_storage_config(array &$data)
|
2021-10-04 11:40:05 +02:00
|
|
|
{
|
2022-01-07 02:14:24 +01:00
|
|
|
if ($data['name'] == WebDav::getName()) {
|
|
|
|
$data['storage_config'] = new WebDavConfig(DI::l10n(), DI::config(), DI::httpClient());
|
|
|
|
}
|
2021-08-25 23:47:18 +02:00
|
|
|
}
|