Completed
Pull Request — master (#26700)
by Philipp
08:19
created

apps/files_external/lib/AppInfo/Application.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * @author Joas Schilling <[email protected]>
4
 * @author Morris Jobke <[email protected]>
5
 * @author Robin Appelman <[email protected]>
6
 * @author Robin McCorkell <[email protected]>
7
 * @author Roeland Jago Douma <[email protected]>
8
 * @author Ross Nicoll <[email protected]>
9
 * @author Vincent Petry <[email protected]>
10
 *
11
 * @copyright Copyright (c) 2016, ownCloud GmbH.
12
 * @license AGPL-3.0
13
 *
14
 * This code is free software: you can redistribute it and/or modify
15
 * it under the terms of the GNU Affero General Public License, version 3,
16
 * as published by the Free Software Foundation.
17
 *
18
 * This program is distributed in the hope that it will be useful,
19
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21
 * GNU Affero General Public License for more details.
22
 *
23
 * You should have received a copy of the GNU Affero General Public License, version 3,
24
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
25
 *
26
 */
27
28
namespace OCA\Files_External\AppInfo;
29
30
use \OCP\AppFramework\App;
31
use OCP\AppFramework\IAppContainer;
32
use \OCP\IContainer;
33
use \OCA\Files_External\Service\BackendService;
34
use \OCA\Files_External\Lib\Config\IBackendProvider;
35
use \OCA\Files_External\Lib\Config\IAuthMechanismProvider;
36
37
/**
38
 * @package OCA\Files_External\AppInfo
39
 */
40
class Application extends App implements IBackendProvider, IAuthMechanismProvider {
41
42
	public function __construct(array $urlParams = []) {
43
		parent::__construct('files_external', $urlParams);
44
45
		$container = $this->getContainer();
46
47
		$container->registerService('OCP\Files\Config\IUserMountCache', function (IAppContainer $c) {
48
			return $c->getServer()->query('UserMountCache');
49
		});
50
51
		$backendService = $container->query('OCA\\Files_External\\Service\\BackendService');
52
		$backendService->registerBackendProvider($this);
53
		$backendService->registerAuthMechanismProvider($this);
54
55
		// force-load auth mechanisms since some will register hooks
56
		// TODO: obsolete these and use the TokenProvider to get the user's password from the session
57
		$this->getAuthMechanisms();
58
59
		// app developers: do NOT depend on this! it will disappear with oC 9.0!
60
		\OC::$server->getEventDispatcher()->dispatch(
61
			'OCA\\Files_External::loadAdditionalBackends'
62
		);
63
	}
64
65
	/**
66
	 * Register settings templates
67
	 */
68
	public function registerSettings() {
69
		$container = $this->getContainer();
70
		$backendService = $container->query('OCA\\Files_External\\Service\\BackendService');
0 ignored issues
show
$backendService is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
71
72
		\OCP\App::registerAdmin('files_external', 'settings');
73
		\OCP\App::registerPersonal('files_external', 'personal');
74
	}
75
76
	/**
77
	 * @{inheritdoc}
78
	 */
79
	public function getBackends() {
80
		$container = $this->getContainer();
81
82
		$backends = [
83
			$container->query('OCA\Files_External\Lib\Backend\Local'),
84
			$container->query('OCA\Files_External\Lib\Backend\DAV'),
85
			$container->query('OCA\Files_External\Lib\Backend\OwnCloud'),
86
			$container->query('OCA\Files_External\Lib\Backend\SFTP'),
87
			$container->query('OCA\Files_External\Lib\Backend\AmazonS3'),
88
			$container->query('OCA\Files_External\Lib\Backend\Dropbox'),
89
			$container->query('OCA\Files_External\Lib\Backend\Google'),
90
			$container->query('OCA\Files_External\Lib\Backend\Swift'),
91
			$container->query('OCA\Files_External\Lib\Backend\SFTP_Key'),
92
			$container->query('OCA\Files_External\Lib\Backend\SMB'),
93
			$container->query('OCA\Files_External\Lib\Backend\SMB_OC'),
94
		];
95
96
		return $backends;
97
	}
98
99
	/**
100
	 * @{inheritdoc}
101
	 */
102
	public function getAuthMechanisms() {
103
		$container = $this->getContainer();
104
105
		return [
106
			// AuthMechanism::SCHEME_NULL mechanism
107
			$container->query('OCA\Files_External\Lib\Auth\NullMechanism'),
108
109
			// AuthMechanism::SCHEME_BUILTIN mechanism
110
			$container->query('OCA\Files_External\Lib\Auth\Builtin'),
111
112
			// AuthMechanism::SCHEME_PASSWORD mechanisms
113
			$container->query('OCA\Files_External\Lib\Auth\Password\Password'),
114
			$container->query('OCA\Files_External\Lib\Auth\Password\SessionCredentials'),
115
116
			// AuthMechanism::SCHEME_OAUTH1 mechanisms
117
			$container->query('OCA\Files_External\Lib\Auth\OAuth1\OAuth1'),
118
119
			// AuthMechanism::SCHEME_OAUTH2 mechanisms
120
			$container->query('OCA\Files_External\Lib\Auth\OAuth2\OAuth2'),
121
122
			// AuthMechanism::SCHEME_PUBLICKEY mechanisms
123
			$container->query('OCA\Files_External\Lib\Auth\PublicKey\RSA'),
124
125
			// AuthMechanism::SCHEME_OPENSTACK mechanisms
126
			$container->query('OCA\Files_External\Lib\Auth\OpenStack\OpenStack'),
127
			$container->query('OCA\Files_External\Lib\Auth\OpenStack\Rackspace'),
128
129
			// Specialized mechanisms
130
			$container->query('OCA\Files_External\Lib\Auth\AmazonS3\AccessKey'),
131
		];
132
	}
133
134
}
135