|
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 OC\Files\Storage\Wrapper\Jail; |
|
12
|
|
|
use OCA\Files_Antivirus\AvirWrapper; |
|
13
|
|
|
use OCA\Files_Antivirus\Scanner\ScannerFactory; |
|
14
|
|
|
use OCP\Activity\IManager; |
|
15
|
|
|
use OCP\AppFramework\App; |
|
16
|
|
|
use OCP\Files\IHomeStorage; |
|
17
|
|
|
use OCP\IL10N; |
|
18
|
|
|
use OCP\ILogger; |
|
19
|
|
|
use Symfony\Component\EventDispatcher\EventDispatcherInterface; |
|
20
|
|
|
|
|
21
|
|
|
class Application extends App { |
|
22
|
|
|
|
|
23
|
|
|
const APP_NAME = 'files_antivirus'; |
|
24
|
|
|
|
|
25
|
5 |
|
public function __construct (array $urlParams = []) { |
|
26
|
5 |
|
parent::__construct(self::APP_NAME, $urlParams); |
|
27
|
5 |
|
} |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Add wrapper for local storages |
|
31
|
|
|
*/ |
|
32
|
1 |
|
public function setupWrapper(){ |
|
33
|
1 |
|
\OC\Files\Filesystem::addStorageWrapper( |
|
34
|
1 |
|
'oc_avir', |
|
35
|
|
|
function ($mountPoint, $storage) { |
|
36
|
|
|
/** |
|
37
|
|
|
* @var \OC\Files\Storage\Storage $storage |
|
38
|
|
|
*/ |
|
39
|
1 |
|
if ($storage->instanceOfStorage(Jail::class)) { |
|
40
|
|
|
// No reason to wrap jails again |
|
41
|
|
|
return $storage; |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
1 |
|
if ($storage instanceof \OC\Files\Storage\Storage) { |
|
|
|
|
|
|
45
|
1 |
|
$container = $this->getContainer(); |
|
46
|
1 |
|
$scannerFactory = $container->query(ScannerFactory::class); |
|
47
|
1 |
|
$l10n = $container->query(IL10N::class); |
|
48
|
1 |
|
$logger = $container->query(ILogger::class); |
|
49
|
1 |
|
$activityManager = $container->query(IManager::class); |
|
50
|
1 |
|
$eventDispatcher = $container->query(EventDispatcherInterface::class); |
|
51
|
1 |
|
return new AvirWrapper([ |
|
52
|
1 |
|
'storage' => $storage, |
|
53
|
1 |
|
'scannerFactory' => $scannerFactory, |
|
54
|
1 |
|
'l10n' => $l10n, |
|
55
|
1 |
|
'logger' => $logger, |
|
56
|
1 |
|
'activityManager' => $activityManager, |
|
57
|
1 |
|
'isHomeStorage' => $storage->instanceOfStorage(IHomeStorage::class), |
|
58
|
1 |
|
'eventDispatcher' => $eventDispatcher, |
|
59
|
|
|
]); |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
return $storage; |
|
63
|
1 |
|
}, |
|
64
|
1 |
|
1 |
|
65
|
|
|
); |
|
66
|
1 |
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
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.