1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* ownCloud - files_antivirus |
4
|
|
|
* |
5
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
6
|
|
|
* later. See the COPYING file. |
7
|
|
|
* |
8
|
|
|
* @author Viktar Dubiniuk <[email protected]> |
9
|
|
|
* |
10
|
|
|
* @copyright Viktar Dubiniuk 2014-2018 |
11
|
|
|
* @license AGPL-3.0 |
12
|
|
|
*/ |
13
|
|
|
|
14
|
|
|
namespace OCA\Files_Antivirus\AppInfo; |
15
|
|
|
|
16
|
|
|
use OCA\Files_Antivirus\AppConfig; |
17
|
|
|
use OCA\Files_Antivirus\AvirWrapper; |
18
|
|
|
use OCA\Files_Antivirus\Controller\RuleController; |
19
|
|
|
use OCA\Files_Antivirus\Controller\SettingsController; |
20
|
|
|
use OCA\Files_Antivirus\Db\RuleMapper; |
21
|
|
|
use OCA\Files_Antivirus\BackgroundScanner; |
22
|
|
|
use OCA\Files_Antivirus\RequestHelper; |
23
|
|
|
use OCA\Files_Antivirus\ScannerFactory; |
24
|
|
|
use OCP\AppFramework\App; |
25
|
|
|
|
26
|
|
|
class Application extends App { |
27
|
27 |
|
public function __construct(array $urlParams = []) { |
28
|
27 |
|
parent::__construct('files_antivirus', $urlParams); |
29
|
|
|
|
30
|
27 |
|
$container = $this->getContainer(); |
31
|
27 |
|
$container->registerService( |
32
|
27 |
|
'RuleController', |
33
|
|
|
function ($c) { |
34
|
|
|
return new RuleController( |
35
|
|
|
$c->query('AppName'), |
36
|
|
|
$c->query('Request'), |
37
|
|
|
$c->query('Logger'), |
38
|
|
|
$c->query('L10N'), |
39
|
|
|
$c->query('RuleMapper') |
40
|
|
|
); |
41
|
|
|
} |
42
|
27 |
|
); |
43
|
27 |
|
$container->registerService( |
44
|
27 |
|
'SettingsController', |
45
|
|
|
function ($c) { |
46
|
|
|
return new SettingsController( |
47
|
|
|
$c->query('Request'), |
48
|
|
|
$c->query('AppConfig'), |
49
|
|
|
$c->query('ScannerFactory'), |
50
|
|
|
$c->query('L10N') |
51
|
|
|
); |
52
|
|
|
} |
53
|
27 |
|
); |
54
|
27 |
|
$container->registerService( |
55
|
27 |
|
'AppConfig', |
56
|
|
|
function ($c) { |
57
|
7 |
|
return new AppConfig( |
58
|
7 |
|
$c->query('CoreConfig') |
59
|
7 |
|
); |
60
|
|
|
} |
61
|
27 |
|
); |
62
|
|
|
|
63
|
27 |
|
$container->registerService( |
64
|
27 |
|
'ScannerFactory', |
65
|
|
|
function ($c) { |
66
|
1 |
|
return new ScannerFactory( |
67
|
1 |
|
$c->query('AppConfig'), |
68
|
1 |
|
$c->query('Logger') |
69
|
1 |
|
); |
70
|
|
|
} |
71
|
27 |
|
); |
72
|
|
|
|
73
|
27 |
|
$container->registerService( |
74
|
27 |
|
'BackgroundScanner', |
75
|
|
|
function ($c) { |
76
|
|
|
return new BackgroundScanner( |
77
|
|
|
$c->query('ScannerFactory'), |
78
|
|
|
$c->query('L10N'), |
79
|
|
|
$c->query('AppConfig'), |
80
|
|
|
$c->getServer()->getRootFolder(), |
81
|
|
|
$c->getServer()->getUserSession() |
82
|
|
|
); |
83
|
|
|
} |
84
|
27 |
|
); |
85
|
|
|
|
86
|
27 |
|
$container->registerService( |
87
|
27 |
|
'RuleMapper', |
88
|
|
|
function ($c) { |
89
|
|
|
return new RuleMapper( |
90
|
|
|
$c->query('ServerContainer')->getDb() |
91
|
|
|
); |
92
|
|
|
} |
93
|
27 |
|
); |
94
|
|
|
|
95
|
27 |
|
$container->registerService( |
96
|
27 |
|
'RequestHelper', |
97
|
|
|
function ($c) { |
98
|
3 |
|
return new RequestHelper( |
99
|
3 |
|
$c->query('ServerContainer')->getRequest() |
100
|
3 |
|
); |
101
|
|
|
} |
102
|
27 |
|
); |
103
|
|
|
|
104
|
|
|
/** |
105
|
|
|
* Core |
106
|
|
|
*/ |
107
|
27 |
|
$container->registerService( |
108
|
27 |
|
'Logger', |
109
|
|
|
function ($c) { |
110
|
15 |
|
return $c->query('ServerContainer')->getLogger(); |
111
|
|
|
} |
112
|
27 |
|
); |
113
|
27 |
|
$container->registerService( |
114
|
27 |
|
'CoreConfig', |
115
|
|
|
function ($c) { |
116
|
12 |
|
return $c->query('ServerContainer')->getConfig(); |
117
|
|
|
} |
118
|
27 |
|
); |
119
|
27 |
|
$container->registerService( |
120
|
27 |
|
'L10N', |
121
|
|
|
function ($c) { |
122
|
1 |
|
return $c->query('ServerContainer')->getL10N($c->query('AppName')); |
123
|
|
|
} |
124
|
27 |
|
); |
125
|
27 |
|
} |
126
|
|
|
|
127
|
|
|
/** |
128
|
|
|
* Add wrapper for local storages |
129
|
|
|
* |
130
|
|
|
* @return void |
131
|
|
|
*/ |
132
|
27 |
|
public function setupWrapper() { |
133
|
3 |
|
\OC\Files\Filesystem::addStorageWrapper( |
134
|
3 |
|
'oc_avir', |
135
|
27 |
|
function ($mountPoint, $storage) { |
136
|
|
|
/** |
137
|
|
|
* @var \OC\Files\Storage\Storage $storage |
138
|
|
|
*/ |
139
|
3 |
|
if ($storage instanceof \OC\Files\Storage\Storage) { |
|
|
|
|
140
|
27 |
|
$appConfig = $this->getContainer()->query('AppConfig'); |
141
|
3 |
|
$scannerFactory = $this->getContainer()->query('ScannerFactory'); |
142
|
3 |
|
$l10n = $this->getContainer()->query('L10N'); |
143
|
3 |
|
$logger = $this->getContainer()->query('Logger'); |
144
|
27 |
|
$requestHelper = $this->getContainer()->query('RequestHelper'); |
145
|
3 |
|
return new AvirWrapper( |
146
|
|
|
[ |
147
|
3 |
|
'storage' => $storage, |
148
|
3 |
|
'appConfig' => $appConfig, |
149
|
3 |
|
'scannerFactory' => $scannerFactory, |
150
|
3 |
|
'l10n' => $l10n, |
151
|
3 |
|
'logger' => $logger, |
152
|
|
|
'requestHelper' => $requestHelper |
153
|
3 |
|
] |
154
|
3 |
|
); |
155
|
|
|
} else { |
156
|
|
|
return $storage; |
157
|
|
|
} |
158
|
3 |
|
}, |
159
|
|
|
1 |
160
|
3 |
|
); |
161
|
3 |
|
} |
162
|
|
|
} |
163
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.json
file (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.json
to be in the root folder of your repository.Are you sure this class is defined by one of your dependencies, or did you maybe not list a dependency in either the
require
orrequire-dev
section?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceof
checks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.