nextcloud-swarm-plugin/lib/AppInfo/Application.php
Karim Vergnes 9f24a793aa
fix(copyref): Copy Swarm Reference issue (#59)
* Resolved conflicts

* fix(copyref): Copy Swarm Reference issue

This is a fix for the Copy Swarm Reference feature. Due to the requirement
for a NPM module @nextcloud/files, the JS feature has been moved to src/
and added to the Webpack build list.

As such, `npm run build` is required to build the relevant JS files and
preview this fix.

---------

Co-authored-by: JoaoSRaposo <joaosraposo@gmail.com>
2024-08-30 19:01:09 +02:00

100 lines
3.1 KiB
PHP
Executable file

<?php
/**
* @copyright Copyright (c) 2022, MetaProvide Holding EKF
*
* @author Ron Trevor <ecoron@proton.me>
*
* @license GNU AGPL version 3 or any later version
*
* 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/>.
*
*/
declare(strict_types=1);
namespace OCA\Files_External_Ethswarm\AppInfo;
use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files_External_Ethswarm\Backend\BeeSwarm;
use OCA\Files_External_Ethswarm\Auth\License;
use OCA\Files_External\Lib\Config\IBackendProvider;
use OCA\Files_External\Service\BackendService;
use OCA\Files_External\Lib\Config\IAuthMechanismProvider;
use OCP\AppFramework\App;
use OCP\Util;
use OCP\AppFramework\Bootstrap\IRegistrationContext;
use OCP\AppFramework\Bootstrap\IBootContext;
use OCP\AppFramework\Bootstrap\IBootstrap;
use OCP\EventDispatcher\IEventDispatcher;
/**
* @package OCA\Files_external_beeswarm\AppInfo
*/
class Application extends App implements IBootstrap, IBackendProvider, IAuthMechanismProvider {
public const APP_ID = 'files_external_ethswarm';
public function __construct(array $urlParams = []) {
parent::__construct(self::APP_ID, $urlParams);
}
/**
* @{inheritdoc}
*/
public function getBackends() {
$container = $this->getContainer();
return [
$container->query(BeeSwarm::class)
];
}
public function boot(IBootContext $context): void {
$context->injectFn([$this, 'registerEventsScripts']);
$context->injectFn(function (BackendService $backendService) {
$backendService->registerBackendProvider($this);
$backendService->registerAuthMechanismProvider($this);
});
// Load custom JS
Util::addScript(SELF::APP_ID, 'admin-settings');
/** @var IEventDispatcher $dispatcher */
$dispatcher = $context->getAppContainer()->get(IEventDispatcher::class);
$dispatcher->addListener('OCA\Files::loadAdditionalScripts', function () {
Util::addScript(SELF::APP_ID, 'fileactions');
Util::addScript(SELF::APP_ID, 'menuobserver');
});
$dispatcher->addListener(LoadAdditionalScriptsEvent::class, function () {
Util::addScript(SELF::APP_ID, 'nextcloud-swarm-plugin-fileactions');
});
$this->getAuthMechanisms();
}
public function registerEventsScripts(IEventDispatcher $dispatcher) {
}
public function register(IRegistrationContext $context): void {
// Register AddContentSecurityPolicyEvent for CSPListener class listenser here
}
public function getAuthMechanisms() {
$container = $this->getContainer();
return [
// AuthMechanism::BASIC HTTP mechanisms
$container->get(License::class),
];
}
}