aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Listener/LoadAdditionalListener.php
blob: b089c8309b78a2a17022b5696c2012fe7d744738 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php

declare(strict_types=1);

/**
 * SPDX-FileCopyrightText: 2019 Nextcloud GmbH and Nextcloud contributors
 * SPDX-License-Identifier: AGPL-3.0-or-later
 */
namespace OCA\Files_Sharing\Listener;

use OCA\Files\Event\LoadAdditionalScriptsEvent;
use OCA\Files_Sharing\AppInfo\Application;
use OCP\EventDispatcher\Event;
use OCP\EventDispatcher\IEventListener;
use OCP\Server;
use OCP\Share\IManager;
use OCP\Util;

/** @template-implements IEventListener<LoadAdditionalScriptsEvent> */
class LoadAdditionalListener implements IEventListener {
	public function handle(Event $event): void {
		if (!($event instanceof LoadAdditionalScriptsEvent)) {
			return;
		}

		// After files for the breadcrumb share indicator
		Util::addScript(Application::APP_ID, 'additionalScripts', 'files');
		Util::addStyle(Application::APP_ID, 'icons');

		$shareManager = Server::get(IManager::class);
		if ($shareManager->shareApiEnabled() && class_exists('\OCA\Files\App')) {
			Util::addInitScript(Application::APP_ID, 'init');
		}
	}
}