Completed
Pull Request — master (#2092)
by Joas
08:22 queued 01:00
created

LegacyFilter::getIdentifier()   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
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Joas Schilling <[email protected]>
4
 *
5
 * @license GNU AGPL version 3 or any later version
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License as
9
 * published by the Free Software Foundation, either version 3 of the
10
 * License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 */
21
22
namespace OC\Activity;
23
24
use OCP\Activity\IFilter;
25
use OCP\Activity\IManager;
26
27
class LegacyFilter implements IFilter {
28
29
	/** @var IManager */
30
	protected $manager;
31
	/** @var string */
32
	protected $identifier;
33
	/** @var string */
34
	protected $name;
35
	/** @var bool */
36
	protected $isTopFilter;
37
38
	/**
39
	 * LegacySetting constructor.
40
	 *
41
	 * @param IManager $manager
42
	 * @param string $identifier
43
	 * @param string $name
44
	 * @param bool $isTopFilter
45
	 */
46
	public function __construct(IManager $manager,
47
								$identifier,
48
								$name,
49
								$isTopFilter) {
50
		$this->manager = $manager;
51
		$this->identifier = $identifier;
52
		$this->name = $name;
53
		$this->isTopFilter = $isTopFilter;
54
	}
55
56
	/**
57
	 * @return string Lowercase a-z and underscore only identifier
58
	 * @since 11.0.0
59
	 */
60
	public function getIdentifier() {
61
		return $this->identifier;
62
	}
63
64
	/**
65
	 * @return string A translated string
66
	 * @since 11.0.0
67
	 */
68
	public function getName() {
69
		return $this->name;
70
	}
71
72
	/**
73
	 * @return int whether the filter should be rather on the top or bottom of
74
	 * the admin section. The filters are arranged in ascending order of the
75
	 * priority values. It is required to return a value between 0 and 100.
76
	 * @since 11.0.0
77
	 */
78
	public function getPriority() {
79
		return $this->isTopFilter ? 40 : 50;
80
	}
81
82
	/**
83
	 * @return string Full URL to an icon, empty string when none is given
84
	 * @since 11.0.0
85
	 */
86
	public function getIcon() {
87
		// Old API was CSS class, so we can not use this...
88
		return '';
89
	}
90
91
	/**
92
	 * @param string[] $types
93
	 * @return string[] An array of allowed apps from which activities should be displayed
94
	 * @since 11.0.0
95
	 */
96
	public function filterTypes(array $types) {
97
		return $this->manager->filterNotificationTypes($types, $this->getIdentifier());
0 ignored issues
show
Deprecated Code introduced by
The method OCP\Activity\IManager::filterNotificationTypes() has been deprecated with message: 11.0.0 - Use getFilterById()->filterTypes() instead

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
98
	}
99
100
	/**
101
	 * @return string[] An array of allowed apps from which activities should be displayed
102
	 * @since 11.0.0
103
	 */
104
	public function allowedApps() {
105
		return [];
106
	}
107
}
108
109