|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* @copyright Copyright (c) 2016, ownCloud, Inc. |
|
4
|
|
|
* @copyright Copyright (c) 2016 Joas Schilling <[email protected]> |
|
5
|
|
|
* |
|
6
|
|
|
* @author Bernhard Posselt <[email protected]> |
|
7
|
|
|
* @author Christoph Wurst <[email protected]> |
|
8
|
|
|
* @author Joas Schilling <[email protected]> |
|
9
|
|
|
* @author Lukas Reschke <[email protected]> |
|
10
|
|
|
* @author Morris Jobke <[email protected]> |
|
11
|
|
|
* @author Roeland Jago Douma <[email protected]> |
|
12
|
|
|
* @author Thomas Müller <[email protected]> |
|
13
|
|
|
* @author Victor Dubiniuk <[email protected]> |
|
14
|
|
|
* |
|
15
|
|
|
* @license AGPL-3.0 |
|
16
|
|
|
* |
|
17
|
|
|
* This code is free software: you can redistribute it and/or modify |
|
18
|
|
|
* it under the terms of the GNU Affero General Public License, version 3, |
|
19
|
|
|
* as published by the Free Software Foundation. |
|
20
|
|
|
* |
|
21
|
|
|
* This program is distributed in the hope that it will be useful, |
|
22
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
23
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
24
|
|
|
* GNU Affero General Public License for more details. |
|
25
|
|
|
* |
|
26
|
|
|
* You should have received a copy of the GNU Affero General Public License, version 3, |
|
27
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/> |
|
28
|
|
|
* |
|
29
|
|
|
*/ |
|
30
|
|
|
|
|
31
|
|
|
namespace OC\Core; |
|
32
|
|
|
|
|
33
|
|
|
use OC\Core\Controller\OCJSController; |
|
34
|
|
|
use OC\Security\IdentityProof\Manager; |
|
35
|
|
|
use OC\Server; |
|
36
|
|
|
use OCP\AppFramework\App; |
|
37
|
|
|
use OC\Core\Controller\CssController; |
|
38
|
|
|
use OCP\AppFramework\Utility\ITimeFactory; |
|
39
|
|
|
use OCP\IRequest; |
|
40
|
|
|
use OCP\Util; |
|
41
|
|
|
|
|
42
|
|
|
/** |
|
43
|
|
|
* Class Application |
|
44
|
|
|
* |
|
45
|
|
|
* @package OC\Core |
|
46
|
|
|
*/ |
|
47
|
|
|
class Application extends App { |
|
48
|
|
|
|
|
49
|
|
|
public function __construct() { |
|
50
|
|
|
parent::__construct('core'); |
|
51
|
|
|
|
|
52
|
|
|
$container = $this->getContainer(); |
|
53
|
|
|
|
|
54
|
|
|
$container->registerService('defaultMailAddress', function () { |
|
55
|
|
|
return Util::getDefaultEmailAddress('lostpassword-noreply'); |
|
56
|
|
|
}); |
|
57
|
|
|
$container->registerService(Manager::class, function () { |
|
58
|
|
|
return new Manager( |
|
59
|
|
|
\OC::$server->getAppDataDir('identityproof'), |
|
60
|
|
|
\OC::$server->getCrypto() |
|
61
|
|
|
); |
|
62
|
|
|
}); |
|
63
|
|
|
$container->registerService(CssController::class, function () use ($container) { |
|
64
|
|
|
return new CssController( |
|
65
|
|
|
$container->query('appName'), |
|
66
|
|
|
$container->query(IRequest::class), |
|
67
|
|
|
\OC::$server->getAppDataDir('css'), |
|
68
|
|
|
$container->query(ITimeFactory::class) |
|
69
|
|
|
); |
|
70
|
|
|
}); |
|
71
|
|
View Code Duplication |
$container->registerService(OCJSController::class, function () use ($container) { |
|
|
|
|
|
|
72
|
|
|
/** @var Server $server */ |
|
73
|
|
|
$server = $container->getServer(); |
|
74
|
|
|
return new OCJSController( |
|
75
|
|
|
$container->query('appName'), |
|
76
|
|
|
$server->getRequest(), |
|
|
|
|
|
|
77
|
|
|
$server->getL10N('core'), |
|
|
|
|
|
|
78
|
|
|
// This is required for the theming to overwrite the `OC_Defaults`, see |
|
79
|
|
|
// https://github.com/nextcloud/server/issues/3148 |
|
80
|
|
|
$server->getThemingDefaults(), |
|
|
|
|
|
|
81
|
|
|
$server->getAppManager(), |
|
|
|
|
|
|
82
|
|
|
$server->getSession(), |
|
|
|
|
|
|
83
|
|
|
$server->getUserSession(), |
|
|
|
|
|
|
84
|
|
|
$server->getConfig(), |
|
|
|
|
|
|
85
|
|
|
$server->getGroupManager(), |
|
|
|
|
|
|
86
|
|
|
$server->getIniWrapper(), |
|
|
|
|
|
|
87
|
|
|
$server->getURLGenerator() |
|
|
|
|
|
|
88
|
|
|
); |
|
89
|
|
|
}); |
|
90
|
|
|
} |
|
91
|
|
|
} |
|
92
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.