mirror of
https://git.friendi.ca/friendica/friendica-addons.git
synced 2024-12-27 11:22:26 +00:00
327bfcb2b5
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.
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(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());
|
|
}
|
|
}
|