Activities   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 55
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A showList() 0 12 2
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud, Inc.
4
 *
5
 * @author Joas Schilling <[email protected]>
6
 *
7
 * @license AGPL-3.0
8
 *
9
 * This code is free software: you can redistribute it and/or modify
10
 * it under the terms of the GNU Affero General Public License, version 3,
11
 * as published by the Free Software Foundation.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License, version 3,
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
20
 *
21
 */
22
23
namespace OCA\Activity\Controller;
24
25
use OCA\Activity\Data;
26
use OCA\Activity\Navigation;
27
use OCP\AppFramework\Controller;
28
use OCP\AppFramework\Http\TemplateResponse;
29
use OCP\IConfig;
30
use OCP\IRequest;
31
use Symfony\Component\EventDispatcher\EventDispatcherInterface;
32
use Symfony\Component\EventDispatcher\GenericEvent;
33
34
class Activities extends Controller {
35
36
	/** @var IConfig */
37
	protected $config;
38
39
	/** @var Data */
40
	protected $data;
41
42
	/** @var Navigation */
43
	protected $navigation;
44
45
	/** @var EventDispatcherInterface */
46
	protected $eventDispatcher;
47
48
	/**
49
	 * @param string $appName
50
	 * @param IRequest $request
51
	 * @param IConfig $config
52
	 * @param Data $data
53
	 * @param Navigation $navigation
54
	 * @param EventDispatcherInterface $eventDispatcher
55
	 */
56 3
	public function __construct($appName,
57
								IRequest $request,
58
								IConfig $config,
59
								Data $data,
60
								Navigation $navigation,
61
								EventDispatcherInterface $eventDispatcher) {
62 3
		parent::__construct($appName, $request);
63 3
		$this->data = $data;
64 3
		$this->config = $config;
65 3
		$this->navigation = $navigation;
66 3
		$this->eventDispatcher = $eventDispatcher;
67 3
	}
68
69
	/**
70
	 * @NoAdminRequired
71
	 * @NoCSRFRequired
72
	 *
73
	 * @param string $filter
74
	 * @return TemplateResponse
75
	 */
76 1
	public function showList($filter = 'all') {
77 1
		$filter = $this->data->validateFilter($filter);
78
79 1
		$event = new GenericEvent($filter);
80 1
		$this->eventDispatcher->dispatch('OCA\Activity::loadAdditionalScripts', $event);
81
82 1
		return new TemplateResponse('activity', 'stream.body', [
83 1
			'appNavigation'	=> $this->navigation->getTemplate($filter),
84 1
			'avatars'		=> $this->config->getSystemValue('enable_avatars', true) ? 'yes' : 'no',
85 1
			'filter'		=> $filter,
86
		]);
87
	}
88
}
89