forked from friendica/friendica-addons
40 lines
1.1 KiB
PHP
40 lines
1.1 KiB
PHP
<?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;
|
|
use Friendica\Addon\webdav_storage\src\WebDavConfig;
|
|
use Friendica\App;
|
|
use Friendica\Core\Hook;
|
|
use Friendica\DI;
|
|
|
|
function webdav_storage_install($a)
|
|
{
|
|
Hook::register('storage_instance' , __FILE__, 'webdav_storage_instance');
|
|
Hook::register('storage_config' , __FILE__, 'webdav_storage_config');
|
|
DI::storageManager()->register(WebDav::class);
|
|
}
|
|
|
|
function webdav_storage_uninstall()
|
|
{
|
|
DI::storageManager()->unregister(WebDav::class);
|
|
}
|
|
|
|
function webdav_storage_instance(array &$data)
|
|
{
|
|
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());
|
|
}
|
|
}
|
|
|
|
function webdav_storage_config(array &$data)
|
|
{
|
|
if ($data['name'] == WebDav::getName()) {
|
|
$data['storage_config'] = new WebDavConfig(DI::l10n(), DI::config(), DI::httpClient());
|
|
}
|
|
}
|