Application   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 39
ccs 0
cts 18
cp 0
rs 10
wmc 7

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addStorageWrapper() 0 3 1
A boot() 0 1 1
A __construct() 0 2 1
A register() 0 3 1
A addStorageWrapperCallback() 0 12 3
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016 Morris Jobke <[email protected]>
4
 *
5
 * @license GNU AGPL version 3 or any later version
6
 *
7
 * This program is free software: you can redistribute it and/or modify
8
 * it under the terms of the GNU Affero General Public License as
9
 * published by the Free Software Foundation, either version 3 of the
10
 * License, or (at your option) any later version.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
19
 *
20
 */
21
22
namespace OCA\FilesAccessControl\AppInfo;
23
24
use OC;
25
use OC\Files\Filesystem;
0 ignored issues
show
Bug introduced by
The type OC\Files\Filesystem was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
26
use OCA\Files_Sharing\SharedStorage;
0 ignored issues
show
Bug introduced by
The type OCA\Files_Sharing\SharedStorage was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
use OCA\FilesAccessControl\Listener\FlowRegisterOperationListener;
28
use OCA\FilesAccessControl\Operation;
29
use OCA\FilesAccessControl\StorageWrapper;
30
use OCP\AppFramework\App;
31
use OCP\AppFramework\Bootstrap\IBootContext;
32
use OCP\AppFramework\Bootstrap\IBootstrap;
33
use OCP\AppFramework\Bootstrap\IRegistrationContext;
34
use OCP\Files\Storage\IStorage;
35
use OCP\Util;
36
use OCP\WorkflowEngine\Events\RegisterOperationsEvent;
37
38
class Application extends App implements IBootstrap {
39
	public function __construct() {
40
		parent::__construct('files_accesscontrol');
41
	}
42
43
	/**
44
	 * @internal
45
	 */
46
	public function addStorageWrapper() {
47
		// Needs to be added as the first layer
48
		Filesystem::addStorageWrapper('files_accesscontrol', [$this, 'addStorageWrapperCallback'], -10);
49
	}
50
51
	/**
52
	 * @internal
53
	 * @param $mountPoint
54
	 * @param IStorage $storage
55
	 * @return StorageWrapper|IStorage
56
	 */
57
	public function addStorageWrapperCallback($mountPoint, IStorage $storage) {
58
		if (!OC::$CLI && !$storage->instanceOfStorage(SharedStorage::class)) {
59
			/** @var Operation $operation */
60
			$operation = $this->getContainer()->get(Operation::class);
61
			return new StorageWrapper([
62
				'storage' => $storage,
63
				'mountPoint' => $mountPoint,
64
				'operation' => $operation,
65
			]);
66
		}
67
68
		return $storage;
69
	}
70
71
	public function register(IRegistrationContext $context): void {
72
		Util::connectHook('OC_Filesystem', 'preSetup', $this, 'addStorageWrapper');
0 ignored issues
show
Deprecated Code introduced by
The function OCP\Util::connectHook() has been deprecated: 21.0.0 use \OCP\EventDispatcher\IEventDispatcher::addListener ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

72
		/** @scrutinizer ignore-deprecated */ Util::connectHook('OC_Filesystem', 'preSetup', $this, 'addStorageWrapper');

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
73
		$context->registerEventListener(RegisterOperationsEvent::class, FlowRegisterOperationListener::class);
74
	}
75
76
	public function boot(IBootContext $context): void {
77
	}
78
}
79