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