Passed
Push — master ( 99d0ba...8af979 )
by Julius
23:28 queued 12s
created

Application::boot()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud GmbH
4
 *
5
 * @author Christoph Wurst <[email protected]>
6
 * @author Roeland Jago Douma <[email protected]>
7
 * @author Vincent Petry <[email protected]>
8
 *
9
 * @license AGPL-3.0
10
 *
11
 * This code is free software: you can redistribute it and/or modify
12
 * it under the terms of the GNU Affero General Public License, version 3,
13
 * as published by the Free Software Foundation.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU Affero General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU Affero General Public License, version 3,
21
 * along with this program. If not, see <http://www.gnu.org/licenses/>
22
 *
23
 */
24
25
namespace OCA\Testing\AppInfo;
26
27
use OCA\Testing\AlternativeHomeUserBackend;
28
use OCP\AppFramework\App;
29
use OCP\AppFramework\Bootstrap\IBootContext;
30
use OCP\AppFramework\Bootstrap\IBootstrap;
31
use OCP\AppFramework\Bootstrap\IRegistrationContext;
32
33
class Application extends App implements IBootstrap {
34
	public function __construct(array $urlParams = []) {
35
		parent::__construct('testing', $urlParams);
36
	}
37
38
	public function register(IRegistrationContext $context): void {
39
	}
40
41
	public function boot(IBootContext $context): void {
42
		$server = $context->getServerContainer();
43
		$config = $server->getConfig();
44
		if ($config->getAppValue('testing', 'enable_alt_user_backend', 'no') === 'yes') {
45
			$userManager = $server->getUserManager();
46
47
			// replace all user backends with this one
48
			$userManager->clearBackends();
49
			$userManager->registerBackend($context->getAppContainer()->get(AlternativeHomeUserBackend::class));
50
		}
51
	}
52
}
53