friendica-addons/webdav_storage/webdav_storage.php
Gidi Kroon 327bfcb2b5 Add name check for webdav configuration options
The webdav_storage addon should check whether it should provide its
config options and its instance based on the provided `$data['name']`.
Not doing this will override the configuration and instance of another
storage add-on.
2022-01-07 02:14:24 +01:00

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(App $a, 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(App $a, array &$data)
{
if ($data['name'] == WebDav::getName()) {
$data['storage_config'] = new WebDavConfig(DI::l10n(), DI::config(), DI::httpClient());
}
}