Application::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 46

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 46
rs 9.1781
c 0
b 0
f 0
1
<?php
2
/**
3
 *
4
 * @author Semih Serhat Karakaya
5
 * @copyright Copyright (c) 2017, ownCloud GmbH.
6
 * @license AGPL-3.0
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
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, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
namespace OCA\Security\AppInfo;
22
23
use OCA\Security\SecurityConfig;
24
use \OCP\AppFramework\App;
25
use \OCA\Security\Throttle;
26
use \OCA\Security\Hooks;
27
use \OCA\Security\Db\DbService;
28
use \OCA\Security\PasswordValidator;
29
30
class Application extends App {
31
32
    public function __construct(array $urlParams=array()){
33
        parent::__construct('security', $urlParams);
34
35
        $container = $this->getContainer();
36
37
        $container->registerService('DbService', function($c) {
38
            return new DbService(
39
                $c->query('ServerContainer')->getDb(),
40
                $c->query('OCP\AppFramework\Utility\ITimeFactory'),
41
                $c->query('SecurityConfig')
42
            );
43
        });
44
45
        $container->registerService('Throttle', function($c) {
46
            return new Throttle(
47
                $c->query('DbService'),
48
                $c->query('SecurityConfig'),
49
                $c->query('OCP\IL10N'),
50
				$c->query('OCP\AppFramework\Utility\ITimeFactory')
51
            );
52
        });
53
54
        $container->registerService('SecurityConfig', function($c) {
55
            return new SecurityConfig(
56
                $c->query('OCP\IConfig')
57
            );
58
        });
59
60
        $container->registerService('PasswordValidator', function($c) {
61
            return new PasswordValidator(
62
                $c->query('SecurityConfig'),
63
                $c->query('OCP\IL10N')
64
            );
65
        });
66
67
        $container->registerService('Hooks', function($c) {
68
            return new Hooks(
69
                $c->query('ServerContainer')->getUserManager(),
70
                $c->query('Throttle'),
71
                $c->query('Request'),
72
                $c->query('PasswordValidator'),
73
                \OC::$server->getEventDispatcher()
74
            );
75
        });
76
77
    }
78
}