friendica-addons/webdav_storage/webdav_storage.php

40 lines
1.1 KiB
PHP
Raw Normal View History

2021-08-25 21:47:18 +00: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 09:40:05 +00:00
use Friendica\Addon\webdav_storage\src\WebDavConfig;
2021-08-25 21:47:18 +00:00
use Friendica\Core\Hook;
use Friendica\DI;
function webdav_storage_install()
2021-08-25 21:47:18 +00:00
{
Hook::register('storage_instance' , __FILE__, 'webdav_storage_instance');
2021-10-04 09:40:05 +00:00
Hook::register('storage_config' , __FILE__, 'webdav_storage_config');
2021-08-25 21:47:18 +00:00
DI::storageManager()->register(WebDav::class);
}
function webdav_storage_uninstall()
{
2021-10-04 09:40:05 +00:00
DI::storageManager()->unregister(WebDav::class);
2021-08-25 21:47:18 +00:00
}
function webdav_storage_instance(array &$data)
2021-08-25 21:47:18 +00: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 09:40:05 +00:00
}
function webdav_storage_config(array &$data)
2021-10-04 09:40:05 +00:00
{
if ($data['name'] == WebDav::getName()) {
$data['storage_config'] = new WebDavConfig(DI::l10n(), DI::config(), DI::httpClient());
}
2021-08-25 21:47:18 +00:00
}