|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Copyright (c) 2015 Victor Dubiniuk <[email protected]> |
|
4
|
|
|
* This file is licensed under the Affero General Public License version 3 or |
|
5
|
|
|
* later. |
|
6
|
|
|
* See the COPYING-README file. |
|
7
|
|
|
*/ |
|
8
|
|
|
|
|
9
|
|
|
namespace OCA\Files_Antivirus\AppInfo; |
|
10
|
|
|
|
|
11
|
|
|
use \OCP\AppFramework\App; |
|
12
|
|
|
|
|
13
|
|
|
use OCA\Files_Antivirus\AppConfig; |
|
14
|
|
|
use OCA\Files_Antivirus\Controller\RuleController; |
|
15
|
|
|
use OCA\Files_Antivirus\Controller\SettingsController; |
|
16
|
|
|
use OCA\Files_Antivirus\Db\RuleMapper; |
|
17
|
|
|
use OCA\Files_Antivirus\BackgroundScanner; |
|
18
|
|
|
use OCA\Files_Antivirus\ScannerFactory; |
|
19
|
|
|
|
|
20
|
|
|
use \OCA\Files_Antivirus\AvirWrapper; |
|
21
|
|
|
use OCP\AppFramework\IAppContainer; |
|
22
|
|
|
|
|
23
|
|
|
class Application extends App { |
|
24
|
10 |
|
public function __construct (array $urlParams = array()) { |
|
25
|
10 |
|
parent::__construct('files_antivirus', $urlParams); |
|
26
|
|
|
|
|
27
|
10 |
|
$container = $this->getContainer(); |
|
28
|
|
|
$container->registerService('RuleController', function(IAppContainer $c) { |
|
29
|
|
|
return new RuleController( |
|
30
|
|
|
$c->query('AppName'), |
|
31
|
|
|
$c->query('Request'), |
|
32
|
|
|
$c->query('Logger'), |
|
33
|
|
|
$c->query('L10N'), |
|
34
|
|
|
$c->query('RuleMapper') |
|
35
|
|
|
); |
|
36
|
10 |
|
}); |
|
37
|
|
|
$container->registerService('SettingsController', function(IAppContainer $c) { |
|
38
|
|
|
return new SettingsController( |
|
39
|
|
|
$c->query('Request'), |
|
40
|
|
|
$c->query('AppConfig'), |
|
41
|
|
|
$c->query('L10N') |
|
42
|
|
|
); |
|
43
|
10 |
|
}); |
|
44
|
|
|
$container->registerService('AppConfig', function(IAppContainer $c) { |
|
45
|
4 |
|
return new AppConfig( |
|
46
|
4 |
|
$c->query('CoreConfig') |
|
47
|
4 |
|
); |
|
48
|
10 |
|
}); |
|
49
|
|
|
|
|
50
|
|
|
$container->registerService('ScannerFactory', function(IAppContainer $c) { |
|
51
|
|
|
return new ScannerFactory( |
|
52
|
|
|
$c->query('AppConfig'), |
|
53
|
|
|
$c->query('Logger') |
|
54
|
|
|
); |
|
55
|
10 |
|
}); |
|
56
|
|
|
|
|
57
|
|
|
$container->registerService('BackgroundScanner', function(IAppContainer $c) { |
|
58
|
|
|
return new BackgroundScanner( |
|
59
|
|
|
$c->query('ScannerFactory'), |
|
60
|
|
|
$c->getServer()->getUserManager(), |
|
61
|
|
|
$c->query('L10N') |
|
62
|
|
|
); |
|
63
|
10 |
|
}); |
|
64
|
|
|
$container->registerService('RuleMapper', function(IAppContainer $c) { |
|
65
|
|
|
return new RuleMapper( |
|
66
|
|
|
$c->getServer()->getDatabaseConnection() |
|
67
|
|
|
); |
|
68
|
10 |
|
}); |
|
69
|
|
|
|
|
70
|
|
|
/** |
|
71
|
|
|
* Core |
|
72
|
|
|
*/ |
|
73
|
|
|
$container->registerService('Logger', function($c) { |
|
74
|
3 |
|
return $c->query('ServerContainer')->getLogger(); |
|
75
|
10 |
|
}); |
|
76
|
|
|
$container->registerService('CoreConfig', function($c) { |
|
77
|
4 |
|
return $c->query('ServerContainer')->getConfig(); |
|
78
|
10 |
|
}); |
|
79
|
|
|
$container->registerService('L10N', function($c) { |
|
80
|
|
|
return $c->query('ServerContainer')->getL10N($c->query('AppName')); |
|
81
|
10 |
|
}); |
|
82
|
|
|
|
|
83
|
10 |
|
} |
|
84
|
|
|
|
|
85
|
|
|
/** |
|
86
|
|
|
* Add wrapper for local storages |
|
87
|
|
|
*/ |
|
88
|
|
|
public function setupWrapper(){ |
|
89
|
|
|
\OC\Files\Filesystem::addStorageWrapper( |
|
90
|
|
|
'oc_avir', |
|
91
|
|
|
function ($mountPoint, $storage) { |
|
92
|
|
|
/** |
|
93
|
|
|
* @var \OC\Files\Storage\Storage $storage |
|
94
|
|
|
*/ |
|
95
|
|
|
if ($storage instanceof \OC\Files\Storage\Storage) { |
|
|
|
|
|
|
96
|
|
|
$scannerFactory = $this->getContainer()->query('ScannerFactory'); |
|
97
|
|
|
$l10n = $this->getContainer()->query('L10N'); |
|
98
|
|
|
$logger = $this->getContainer()->query('Logger'); |
|
99
|
|
|
return new AvirWrapper([ |
|
100
|
|
|
'storage' => $storage, |
|
101
|
|
|
'scannerFactory' => $scannerFactory, |
|
102
|
|
|
'l10n' => $l10n, |
|
103
|
|
|
'logger' => $logger |
|
104
|
|
|
]); |
|
105
|
|
|
} else { |
|
106
|
|
|
return $storage; |
|
107
|
|
|
} |
|
108
|
|
|
}, |
|
109
|
|
|
1 |
|
110
|
|
|
); |
|
111
|
|
|
} |
|
112
|
|
|
} |
|
113
|
|
|
|
This error could be the result of:
1. Missing dependencies
PHP Analyzer uses your
composer.jsonfile (if available) to determine the dependencies of your project and to determine all the available classes and functions. It expects thecomposer.jsonto 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
requireorrequire-devsection?2. Missing use statement
PHP does not complain about undefined classes in
ìnstanceofchecks. For example, the following PHP code will work perfectly fine:If you have not tested against this specific condition, such errors might go unnoticed.