Passed
Push — master ( 48213a...3377c3 )
by Pauli
14:42
created

loadEmbeddedMusicPlayer()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * ownCloud - Music app
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the COPYING file.
8
 *
9
 * @author Morris Jobke <[email protected]>
10
 * @author Pauli Järvinen <[email protected]>
11
 * @copyright Morris Jobke 2013, 2014
12
 * @copyright Pauli Järvinen 2017 - 2024
13
 */
14
15
/**
16
 * Bootstrapping for ownCloud. The release.sh script will remove this file from
17
 * the Nextcloud releases. See https://github.com/owncloud/music/issues/1043.
18
 */
19
20
namespace OCA\Music\AppInfo;
21
22
$app = \OC::$server->query(Application::class);
23
$app->init();
24
25
$c = $app->getContainer();
26
$server = $c->getServer();
27
$appName = $c->query('AppName');
28
29
/**
30
 * add navigation
31
 */
32
$server->getNavigationManager()->add(function () use ($c, $appName) {
33
	$l10n = $c->query('L10N');
34
	$urlGenerator = $c->query('URLGenerator');
35
	return [
36
		'id' => $appName,
37
		'order' => 10,
38
		'name' => $l10n->t('Music'),
39
		'href' => $urlGenerator->linkToRoute('music.page.index'),
40
		'icon' => $urlGenerator->imagePath($appName, 'music.svg')
41
	];
42
});
43
44
/**
45
 * register search provider
46
 */
47
$server->getSearch()->registerProvider(
48
		'OCA\Music\Search\Provider',
49
		['app' => $appName, 'apps' => ['files']]
50
);
51
52
/**
53
 * register the embedded player for Files and Files_Sharing
54
 */
55
$loadEmbeddedMusicPlayer = function() use ($app) {
56
	$app->loadEmbeddedMusicPlayer();
57
};
58
$dispatcher = $server->getEventDispatcher();
59
$dispatcher->addListener('OCA\Files::loadAdditionalScripts', $loadEmbeddedMusicPlayer);
60
$dispatcher->addListener('OCA\Files_Sharing::loadAdditionalScripts', $loadEmbeddedMusicPlayer);
61