Completed
Push — master ( a3ad36...94efe3 )
by Pauli
32s queued 16s
created

MusicWidget::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
rs 10
1
<?php declare(strict_types=1);
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 Pauli Järvinen <[email protected]>
10
 * @copyright Pauli Järvinen 2024
11
 */
12
13
namespace OCA\Music\Dashboard;
14
15
use OCP\Dashboard\IWidget;
16
use OCP\IL10N;
17
use OCP\IURLGenerator;
18
19
/**
20
 * Widget for the Nextcloud Dashboard. This class is not used on ownCloud.
21
 */
22
class MusicWidget implements IWidget
23
{
24
	private $l10n;
25
	private $urlGenerator;
26
27
	public function __construct(IL10N $l10n, IURLGenerator $urlGenerator) {
28
		$this->l10n = $l10n;
29
		$this->urlGenerator = $urlGenerator;
30
	}
31
32
	/**
33
	 * @return string Unique id that identifies the widget, e.g. the app id
34
	 */
35
	public function getId() : string
36
	{
37
		return 'music';
38
	}
39
40
	/**
41
	 * @return string User facing title of the widget
42
	 */
43
	public function getTitle() : string
44
	{
45
		return $this->l10n->t('Music');
46
	}
47
48
	/**
49
	 * @return int Initial order for widget sorting in the range of 10-100, 0-9 are reserved for shipped apps
50
	 */
51
	public function getOrder() : int
52
	{
53
		return 10;
54
	}
55
56
	/**
57
	 * @return string css class that displays an icon next to the widget title
58
	 */
59
	public function getIconClass() : string
60
	{
61
		return 'icon-music-app';
62
	}
63
64
	/**
65
	 * @return string|null The absolute url to the apps own view
66
	 */
67
	public function getUrl() : ?string
68
	{
69
		return $this->urlGenerator->linkToRouteAbsolute('music.page.index');
70
	}
71
72
	/**
73
	 * Execute widget bootstrap code like loading scripts and providing initial state
74
	 */
75
	public function load() : void
76
	{
77
		\OCA\Music\Utility\HtmlUtil::addWebpackScript('dashboard_music_widget');
78
		\OCA\Music\Utility\HtmlUtil::addWebpackStyle('dashboard_music_widget');
79
	}
80
}
81