mirror of
https://github.com/nextcloud/app_api.git
synced 2025-08-15 23:21:56 +00:00
88 lines
2.7 KiB
PHP
88 lines
2.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/**
|
|
*
|
|
* Nextcloud - App Ecosystem V2
|
|
*
|
|
* @copyright Copyright (c) 2023 Andrey Borysenko <andrey18106x@gmail.com>
|
|
*
|
|
* @copyright Copyright (c) 2023 Alexander Piskun <bigcat88@icloud.com>
|
|
*
|
|
* @author 2023 Andrey Borysenko <andrey18106x@gmail.com>
|
|
*
|
|
* @license AGPL-3.0-or-later
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License, or (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
namespace OCA\AppEcosystemV2\AppInfo;
|
|
|
|
use Psr\Container\ContainerInterface;
|
|
|
|
use OCP\AppFramework\App;
|
|
use OCP\AppFramework\Bootstrap\IRegistrationContext;
|
|
use OCP\AppFramework\Bootstrap\IBootContext;
|
|
use OCP\AppFramework\Bootstrap\IBootstrap;
|
|
use OCP\SabrePluginEvent;
|
|
|
|
use OCA\Files\Event\LoadAdditionalScriptsEvent;
|
|
|
|
use OCA\AppEcosystemV2\Capabilities;
|
|
use OCA\AppEcosystemV2\DavPlugin;
|
|
use OCA\AppEcosystemV2\Listener\LoadFilesPluginListener;
|
|
use OCA\AppEcosystemV2\Middleware\AEAuthMiddleware;
|
|
use OCA\AppEcosystemV2\Service\AppEcosystemV2Service;
|
|
use OCP\IRequest;
|
|
use OCP\ISession;
|
|
|
|
class Application extends App implements IBootstrap {
|
|
public const APP_ID = 'app_ecosystem_v2';
|
|
|
|
public const CACHE_TTL = 3600;
|
|
public const ICON_CACHE_TTL = 60 * 60 *24;
|
|
|
|
public function __construct(array $urlParams = []) {
|
|
parent::__construct(self::APP_ID, $urlParams);
|
|
}
|
|
|
|
public function register(IRegistrationContext $context): void {
|
|
$context->registerEventListener(LoadAdditionalScriptsEvent::class, LoadFilesPluginListener::class);
|
|
$context->registerCapability(Capabilities::class);
|
|
$context->registerMiddleware(AEAuthMiddleware::class);
|
|
$context->registerService(DavPlugin::class, function (ContainerInterface $c) {
|
|
return new DavPlugin(
|
|
$c->get(IRequest::class),
|
|
$c->get(ISession::class),
|
|
$c->get(AppEcosystemV2Service::class)
|
|
);
|
|
});
|
|
}
|
|
|
|
public function boot(IBootContext $context): void {
|
|
}
|
|
|
|
public function registerDavAuth() {
|
|
$container = $this->getContainer();
|
|
|
|
$dispatcher = $container->getServer()->getEventDispatcher();
|
|
$dispatcher->addListener('OCA\DAV\Connector\Sabre::addPlugin', function (SabrePluginEvent $event) use ($container) {
|
|
$event->getServer()->addPlugin($container->query(DavPlugin::class));
|
|
});
|
|
}
|
|
}
|
|
|