Passed
Push — master ( 789e21...3cf46e )
by Roeland
29:38 queued 17:41
created

BeforeTemplateRenderedEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 28
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getResponse() 0 2 1
A isLoggedIn() 0 2 1
A __construct() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * @copyright Copyright (c) 2020, Roeland Jago Douma <[email protected]>
7
 *
8
 * @author Morris Jobke <[email protected]>
9
 * @author Roeland Jago Douma <[email protected]>
10
 *
11
 * @license GNU AGPL version 3 or any later version
12
 *
13
 * This program is free software: you can redistribute it and/or modify
14
 * it under the terms of the GNU Affero General Public License as
15
 * published by the Free Software Foundation, either version 3 of the
16
 * License, or (at your option) any later version.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
21
 * GNU Affero General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU Affero General Public License
24
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25
 *
26
 */
27
28
namespace OCP\AppFramework\Http\Events;
29
30
use OCP\AppFramework\Http\TemplateResponse;
31
use OCP\EventDispatcher\Event;
32
33
/**
34
 * Emitted before the rendering step of each TemplateResponse. The event holds a
35
 * flag that specifies if an user is logged in.
36
 *
37
 * @since 20.0.0
38
 */
39
class BeforeTemplateRenderedEvent extends Event {
40
	/** @var bool */
41
	private $loggedIn;
42
	/** @var TemplateResponse */
43
	private $response;
44
45
	/**
46
	 * @since 20.0.0
47
	 */
48
	public function __construct(bool $loggedIn, TemplateResponse $response) {
49
		parent::__construct();
50
51
		$this->loggedIn = $loggedIn;
52
		$this->response = $response;
53
	}
54
55
	/**
56
	 * @since 20.0.0
57
	 */
58
	public function isLoggedIn(): bool {
59
		return $this->loggedIn;
60
	}
61
62
	/**
63
	 * @since 20.0.0
64
	 */
65
	public function getResponse(): TemplateResponse {
66
		return $this->response;
67
	}
68
}
69