Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.
Common duplication problems, and corresponding solutions are:
Complex classes like Server often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Server, and based on these observations, apply Extract Interface, too.
| 1 | <?php |
||
| 99 | class Server extends ServerContainer implements IServerContainer { |
||
| 100 | /** @var string */ |
||
| 101 | private $webRoot; |
||
| 102 | |||
| 103 | /** |
||
| 104 | * @param string $webRoot |
||
| 105 | * @param \OC\Config $config |
||
| 106 | */ |
||
| 107 | public function __construct($webRoot, \OC\Config $config) { |
||
| 108 | parent::__construct(); |
||
| 109 | $this->webRoot = $webRoot; |
||
| 110 | |||
| 111 | $this->registerService('ContactsManager', function ($c) { |
||
|
|
|||
| 112 | return new ContactsManager(); |
||
| 113 | }); |
||
| 114 | |||
| 115 | $this->registerService('PreviewManager', function (Server $c) { |
||
| 116 | return new PreviewManager($c->getConfig()); |
||
| 117 | }); |
||
| 118 | |||
| 119 | $this->registerService('EncryptionManager', function (Server $c) { |
||
| 120 | $view = new View(); |
||
| 121 | $util = new Encryption\Util( |
||
| 122 | $view, |
||
| 123 | $c->getUserManager(), |
||
| 124 | $c->getGroupManager(), |
||
| 125 | $c->getConfig() |
||
| 126 | ); |
||
| 127 | return new Encryption\Manager( |
||
| 128 | $c->getConfig(), |
||
| 129 | $c->getLogger(), |
||
| 130 | $c->getL10N('core'), |
||
| 131 | new View(), |
||
| 132 | $util, |
||
| 133 | new ArrayCache() |
||
| 134 | ); |
||
| 135 | }); |
||
| 136 | |||
| 137 | $this->registerService('EncryptionFileHelper', function (Server $c) { |
||
| 138 | $util = new Encryption\Util( |
||
| 139 | new View(), |
||
| 140 | $c->getUserManager(), |
||
| 141 | $c->getGroupManager(), |
||
| 142 | $c->getConfig() |
||
| 143 | ); |
||
| 144 | return new Encryption\File($util); |
||
| 145 | }); |
||
| 146 | |||
| 147 | $this->registerService('EncryptionKeyStorage', function (Server $c) { |
||
| 148 | $view = new View(); |
||
| 149 | $util = new Encryption\Util( |
||
| 150 | $view, |
||
| 151 | $c->getUserManager(), |
||
| 152 | $c->getGroupManager(), |
||
| 153 | $c->getConfig() |
||
| 154 | ); |
||
| 155 | |||
| 156 | return new Encryption\Keys\Storage($view, $util); |
||
| 157 | }); |
||
| 158 | $this->registerService('TagMapper', function (Server $c) { |
||
| 159 | return new TagMapper($c->getDatabaseConnection()); |
||
| 160 | }); |
||
| 161 | $this->registerService('TagManager', function (Server $c) { |
||
| 162 | $tagMapper = $c->query('TagMapper'); |
||
| 163 | return new TagManager($tagMapper, $c->getUserSession()); |
||
| 164 | }); |
||
| 165 | View Code Duplication | $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 166 | $config = $c->getConfig(); |
||
| 167 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
||
| 168 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
||
| 169 | $factory = new $factoryClass($this); |
||
| 170 | return $factory; |
||
| 171 | }); |
||
| 172 | $this->registerService('SystemTagManager', function (Server $c) { |
||
| 173 | return $c->query('SystemTagManagerFactory')->getManager(); |
||
| 174 | }); |
||
| 175 | $this->registerService('SystemTagObjectMapper', function (Server $c) { |
||
| 176 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
||
| 177 | }); |
||
| 178 | $this->registerService('RootFolder', function () { |
||
| 179 | $manager = \OC\Files\Filesystem::getMountManager(null); |
||
| 180 | $view = new View(); |
||
| 181 | $root = new Root($manager, $view, null); |
||
| 182 | $connector = new HookConnector($root, $view); |
||
| 183 | $connector->viewToNode(); |
||
| 184 | return $root; |
||
| 185 | }); |
||
| 186 | $this->registerService('LazyRootFolder', function(Server $c) { |
||
| 187 | return new LazyRoot(function() use ($c) { |
||
| 188 | return $c->query('RootFolder'); |
||
| 189 | }); |
||
| 190 | }); |
||
| 191 | $this->registerService('UserManager', function (Server $c) { |
||
| 192 | $config = $c->getConfig(); |
||
| 193 | return new \OC\User\Manager($config); |
||
| 194 | }); |
||
| 195 | $this->registerService('GroupManager', function (Server $c) { |
||
| 196 | $groupManager = new \OC\Group\Manager($this->getUserManager()); |
||
| 197 | $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
||
| 198 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
||
| 199 | }); |
||
| 200 | $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
||
| 201 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
||
| 202 | }); |
||
| 203 | $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
||
| 204 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
||
| 205 | }); |
||
| 206 | $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
||
| 207 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
||
| 208 | }); |
||
| 209 | $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
||
| 210 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
||
| 211 | }); |
||
| 212 | $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
||
| 213 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
||
| 214 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
||
| 215 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
||
| 216 | }); |
||
| 217 | return $groupManager; |
||
| 218 | }); |
||
| 219 | $this->registerService('OC\Authentication\Token\DefaultTokenMapper', function (Server $c) { |
||
| 220 | $dbConnection = $c->getDatabaseConnection(); |
||
| 221 | return new Authentication\Token\DefaultTokenMapper($dbConnection); |
||
| 222 | }); |
||
| 223 | $this->registerService('OC\Authentication\Token\DefaultTokenProvider', function (Server $c) { |
||
| 224 | $mapper = $c->query('OC\Authentication\Token\DefaultTokenMapper'); |
||
| 225 | $crypto = $c->getCrypto(); |
||
| 226 | $config = $c->getConfig(); |
||
| 227 | $logger = $c->getLogger(); |
||
| 228 | $timeFactory = new TimeFactory(); |
||
| 229 | return new \OC\Authentication\Token\DefaultTokenProvider($mapper, $crypto, $config, $logger, $timeFactory); |
||
| 230 | }); |
||
| 231 | $this->registerAlias('OC\Authentication\Token\IProvider', 'OC\Authentication\Token\DefaultTokenProvider'); |
||
| 232 | $this->registerService('UserSession', function (Server $c) { |
||
| 233 | $manager = $c->getUserManager(); |
||
| 234 | $session = new \OC\Session\Memory(''); |
||
| 235 | $timeFactory = new TimeFactory(); |
||
| 236 | // Token providers might require a working database. This code |
||
| 237 | // might however be called when ownCloud is not yet setup. |
||
| 238 | View Code Duplication | if (\OC::$server->getSystemConfig()->getValue('installed', false)) { |
|
| 239 | $defaultTokenProvider = $c->query('OC\Authentication\Token\IProvider'); |
||
| 240 | } else { |
||
| 241 | $defaultTokenProvider = null; |
||
| 242 | } |
||
| 243 | |||
| 244 | $userSession = new \OC\User\Session($manager, $session, $timeFactory, $defaultTokenProvider, $c->getConfig()); |
||
| 245 | $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
||
| 246 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
||
| 247 | }); |
||
| 248 | $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
||
| 249 | /** @var $user \OC\User\User */ |
||
| 250 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
||
| 251 | }); |
||
| 252 | $userSession->listen('\OC\User', 'preDelete', function ($user) { |
||
| 253 | /** @var $user \OC\User\User */ |
||
| 254 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
||
| 255 | }); |
||
| 256 | $userSession->listen('\OC\User', 'postDelete', function ($user) { |
||
| 257 | /** @var $user \OC\User\User */ |
||
| 258 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
||
| 259 | }); |
||
| 260 | View Code Duplication | $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 261 | /** @var $user \OC\User\User */ |
||
| 262 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
||
| 263 | }); |
||
| 264 | View Code Duplication | $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 265 | /** @var $user \OC\User\User */ |
||
| 266 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
||
| 267 | }); |
||
| 268 | $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
||
| 269 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
||
| 270 | }); |
||
| 271 | $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
||
| 272 | /** @var $user \OC\User\User */ |
||
| 273 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
||
| 274 | }); |
||
| 275 | $userSession->listen('\OC\User', 'logout', function () { |
||
| 276 | \OC_Hook::emit('OC_User', 'logout', array()); |
||
| 277 | }); |
||
| 278 | $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
||
| 279 | /** @var $user \OC\User\User */ |
||
| 280 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
||
| 281 | }); |
||
| 282 | return $userSession; |
||
| 283 | }); |
||
| 284 | |||
| 285 | $this->registerService('\OC\Authentication\TwoFactorAuth\Manager', function (Server $c) { |
||
| 286 | return new \OC\Authentication\TwoFactorAuth\Manager($c->getAppManager(), $c->getSession(), $c->getConfig()); |
||
| 287 | }); |
||
| 288 | |||
| 289 | $this->registerService('NavigationManager', function ($c) { |
||
| 290 | return new \OC\NavigationManager(); |
||
| 291 | }); |
||
| 292 | $this->registerService('AllConfig', function (Server $c) { |
||
| 293 | return new \OC\AllConfig( |
||
| 294 | $c->getSystemConfig() |
||
| 295 | ); |
||
| 296 | }); |
||
| 297 | $this->registerService('SystemConfig', function ($c) use ($config) { |
||
| 298 | return new \OC\SystemConfig($config); |
||
| 299 | }); |
||
| 300 | $this->registerService('AppConfig', function (Server $c) { |
||
| 301 | return new \OC\AppConfig($c->getDatabaseConnection()); |
||
| 302 | }); |
||
| 303 | $this->registerService('L10NFactory', function (Server $c) { |
||
| 304 | return new \OC\L10N\Factory( |
||
| 305 | $c->getConfig(), |
||
| 306 | $c->getRequest(), |
||
| 307 | $c->getUserSession(), |
||
| 308 | \OC::$SERVERROOT |
||
| 309 | ); |
||
| 310 | }); |
||
| 311 | $this->registerService('URLGenerator', function (Server $c) { |
||
| 312 | $config = $c->getConfig(); |
||
| 313 | $cacheFactory = $c->getMemCacheFactory(); |
||
| 314 | return new \OC\URLGenerator( |
||
| 315 | $config, |
||
| 316 | $cacheFactory |
||
| 317 | ); |
||
| 318 | }); |
||
| 319 | $this->registerService('AppHelper', function ($c) { |
||
| 320 | return new \OC\AppHelper(); |
||
| 321 | }); |
||
| 322 | $this->registerService('UserCache', function ($c) { |
||
| 323 | return new Cache\File(); |
||
| 324 | }); |
||
| 325 | $this->registerService('MemCacheFactory', function (Server $c) { |
||
| 326 | $config = $c->getConfig(); |
||
| 327 | |||
| 328 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
||
| 329 | $v = \OC_App::getAppVersions(); |
||
| 330 | $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
||
| 331 | $version = implode(',', $v); |
||
| 332 | $instanceId = \OC_Util::getInstanceId(); |
||
| 333 | $path = \OC::$SERVERROOT; |
||
| 334 | $prefix = md5($instanceId . '-' . $version . '-' . $path); |
||
| 335 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
||
| 336 | $config->getSystemValue('memcache.local', null), |
||
| 337 | $config->getSystemValue('memcache.distributed', null), |
||
| 338 | $config->getSystemValue('memcache.locking', null) |
||
| 339 | ); |
||
| 340 | } |
||
| 341 | |||
| 342 | return new \OC\Memcache\Factory('', $c->getLogger(), |
||
| 343 | '\\OC\\Memcache\\ArrayCache', |
||
| 344 | '\\OC\\Memcache\\ArrayCache', |
||
| 345 | '\\OC\\Memcache\\ArrayCache' |
||
| 346 | ); |
||
| 347 | }); |
||
| 348 | $this->registerService('RedisFactory', function (Server $c) { |
||
| 349 | $systemConfig = $c->getSystemConfig(); |
||
| 350 | return new RedisFactory($systemConfig); |
||
| 351 | }); |
||
| 352 | $this->registerService('ActivityManager', function (Server $c) { |
||
| 353 | return new \OC\Activity\Manager( |
||
| 354 | $c->getRequest(), |
||
| 355 | $c->getUserSession(), |
||
| 356 | $c->getConfig() |
||
| 357 | ); |
||
| 358 | }); |
||
| 359 | $this->registerService('AvatarManager', function (Server $c) { |
||
| 360 | return new AvatarManager( |
||
| 361 | $c->getUserManager(), |
||
| 362 | $c->getAppDataDir('avatar'), |
||
| 363 | $c->getL10N('lib'), |
||
| 364 | $c->getLogger(), |
||
| 365 | $c->getConfig() |
||
| 366 | ); |
||
| 367 | }); |
||
| 368 | $this->registerService('Logger', function (Server $c) { |
||
| 369 | $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'file'); |
||
| 370 | // TODO: Drop backwards compatibility for config in the future |
||
| 371 | $logger = 'OC\\Log\\' . ucfirst($logClass=='owncloud' ? 'file' : $logClass); |
||
| 372 | call_user_func(array($logger, 'init')); |
||
| 373 | |||
| 374 | return new Log($logger); |
||
| 375 | }); |
||
| 376 | $this->registerService('JobList', function (Server $c) { |
||
| 377 | $config = $c->getConfig(); |
||
| 378 | return new \OC\BackgroundJob\JobList( |
||
| 379 | $c->getDatabaseConnection(), |
||
| 380 | $config, |
||
| 381 | new TimeFactory() |
||
| 382 | ); |
||
| 383 | }); |
||
| 384 | $this->registerService('Router', function (Server $c) { |
||
| 385 | $cacheFactory = $c->getMemCacheFactory(); |
||
| 386 | $logger = $c->getLogger(); |
||
| 387 | if ($cacheFactory->isAvailable()) { |
||
| 388 | $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
||
| 389 | } else { |
||
| 390 | $router = new \OC\Route\Router($logger); |
||
| 391 | } |
||
| 392 | return $router; |
||
| 393 | }); |
||
| 394 | $this->registerService('Search', function ($c) { |
||
| 395 | return new Search(); |
||
| 396 | }); |
||
| 397 | $this->registerService('SecureRandom', function ($c) { |
||
| 398 | return new SecureRandom(); |
||
| 399 | }); |
||
| 400 | $this->registerService('Crypto', function (Server $c) { |
||
| 401 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
||
| 402 | }); |
||
| 403 | $this->registerService('Hasher', function (Server $c) { |
||
| 404 | return new Hasher($c->getConfig()); |
||
| 405 | }); |
||
| 406 | $this->registerService('CredentialsManager', function (Server $c) { |
||
| 407 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
||
| 408 | }); |
||
| 409 | $this->registerService('DatabaseConnection', function (Server $c) { |
||
| 410 | $factory = new \OC\DB\ConnectionFactory(); |
||
| 411 | $systemConfig = $c->getSystemConfig(); |
||
| 412 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
||
| 413 | if (!$factory->isValidType($type)) { |
||
| 414 | throw new \OC\DatabaseException('Invalid database type'); |
||
| 415 | } |
||
| 416 | $connectionParams = $factory->createConnectionParams($systemConfig); |
||
| 417 | $connection = $factory->getConnection($type, $connectionParams); |
||
| 418 | $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
||
| 419 | return $connection; |
||
| 420 | }); |
||
| 421 | $this->registerService('Db', function (Server $c) { |
||
| 422 | return new Db($c->getDatabaseConnection()); |
||
| 423 | }); |
||
| 424 | $this->registerService('HTTPHelper', function (Server $c) { |
||
| 425 | $config = $c->getConfig(); |
||
| 426 | return new HTTPHelper( |
||
| 427 | $config, |
||
| 428 | $c->getHTTPClientService() |
||
| 429 | ); |
||
| 430 | }); |
||
| 431 | $this->registerService('HttpClientService', function (Server $c) { |
||
| 432 | $user = \OC_User::getUser(); |
||
| 433 | $uid = $user ? $user : null; |
||
| 434 | return new ClientService( |
||
| 435 | $c->getConfig(), |
||
| 436 | new \OC\Security\CertificateManager($uid, new View(), $c->getConfig()) |
||
| 437 | ); |
||
| 438 | }); |
||
| 439 | $this->registerService('EventLogger', function (Server $c) { |
||
| 440 | if ($c->getSystemConfig()->getValue('debug', false)) { |
||
| 441 | return new EventLogger(); |
||
| 442 | } else { |
||
| 443 | return new NullEventLogger(); |
||
| 444 | } |
||
| 445 | }); |
||
| 446 | $this->registerService('QueryLogger', function (Server $c) { |
||
| 447 | if ($c->getSystemConfig()->getValue('debug', false)) { |
||
| 448 | return new QueryLogger(); |
||
| 449 | } else { |
||
| 450 | return new NullQueryLogger(); |
||
| 451 | } |
||
| 452 | }); |
||
| 453 | $this->registerService('TempManager', function (Server $c) { |
||
| 454 | return new TempManager( |
||
| 455 | $c->getLogger(), |
||
| 456 | $c->getConfig() |
||
| 457 | ); |
||
| 458 | }); |
||
| 459 | $this->registerService('AppManager', function (Server $c) { |
||
| 460 | return new \OC\App\AppManager( |
||
| 461 | $c->getUserSession(), |
||
| 462 | $c->getAppConfig(), |
||
| 463 | $c->getGroupManager(), |
||
| 464 | $c->getMemCacheFactory(), |
||
| 465 | $c->getEventDispatcher() |
||
| 466 | ); |
||
| 467 | }); |
||
| 468 | $this->registerService('DateTimeZone', function (Server $c) { |
||
| 469 | return new DateTimeZone( |
||
| 470 | $c->getConfig(), |
||
| 471 | $c->getSession() |
||
| 472 | ); |
||
| 473 | }); |
||
| 474 | $this->registerService('DateTimeFormatter', function (Server $c) { |
||
| 475 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
||
| 476 | |||
| 477 | return new DateTimeFormatter( |
||
| 478 | $c->getDateTimeZone()->getTimeZone(), |
||
| 479 | $c->getL10N('lib', $language) |
||
| 480 | ); |
||
| 481 | }); |
||
| 482 | $this->registerService('UserMountCache', function (Server $c) { |
||
| 483 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
||
| 484 | $listener = new UserMountCacheListener($mountCache); |
||
| 485 | $listener->listen($c->getUserManager()); |
||
| 486 | return $mountCache; |
||
| 487 | }); |
||
| 488 | $this->registerService('MountConfigManager', function (Server $c) { |
||
| 489 | $loader = \OC\Files\Filesystem::getLoader(); |
||
| 490 | $mountCache = $c->query('UserMountCache'); |
||
| 491 | $manager = new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
||
| 492 | |||
| 493 | // builtin providers |
||
| 494 | |||
| 495 | $config = $c->getConfig(); |
||
| 496 | $manager->registerProvider(new CacheMountProvider($config)); |
||
| 497 | $manager->registerHomeProvider(new LocalHomeMountProvider()); |
||
| 498 | $manager->registerHomeProvider(new ObjectHomeMountProvider($config)); |
||
| 499 | |||
| 500 | return $manager; |
||
| 501 | }); |
||
| 502 | $this->registerService('IniWrapper', function ($c) { |
||
| 503 | return new IniGetWrapper(); |
||
| 504 | }); |
||
| 505 | $this->registerService('AsyncCommandBus', function (Server $c) { |
||
| 506 | $jobList = $c->getJobList(); |
||
| 507 | return new AsyncBus($jobList); |
||
| 508 | }); |
||
| 509 | $this->registerService('TrustedDomainHelper', function ($c) { |
||
| 510 | return new TrustedDomainHelper($this->getConfig()); |
||
| 511 | }); |
||
| 512 | $this->registerService('Throttler', function(Server $c) { |
||
| 513 | return new Throttler( |
||
| 514 | $c->getDatabaseConnection(), |
||
| 515 | new TimeFactory(), |
||
| 516 | $c->getLogger(), |
||
| 517 | $c->getConfig() |
||
| 518 | ); |
||
| 519 | }); |
||
| 520 | $this->registerService('IntegrityCodeChecker', function (Server $c) { |
||
| 521 | // IConfig and IAppManager requires a working database. This code |
||
| 522 | // might however be called when ownCloud is not yet setup. |
||
| 523 | if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
||
| 524 | $config = $c->getConfig(); |
||
| 525 | $appManager = $c->getAppManager(); |
||
| 526 | } else { |
||
| 527 | $config = null; |
||
| 528 | $appManager = null; |
||
| 529 | } |
||
| 530 | |||
| 531 | return new Checker( |
||
| 532 | new EnvironmentHelper(), |
||
| 533 | new FileAccessHelper(), |
||
| 534 | new AppLocator(), |
||
| 535 | $config, |
||
| 536 | $c->getMemCacheFactory(), |
||
| 537 | $appManager, |
||
| 538 | $c->getTempManager() |
||
| 539 | ); |
||
| 540 | }); |
||
| 541 | $this->registerService('Request', function ($c) { |
||
| 542 | if (isset($this['urlParams'])) { |
||
| 543 | $urlParams = $this['urlParams']; |
||
| 544 | } else { |
||
| 545 | $urlParams = []; |
||
| 546 | } |
||
| 547 | |||
| 548 | if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
||
| 549 | && in_array('fakeinput', stream_get_wrappers()) |
||
| 550 | ) { |
||
| 551 | $stream = 'fakeinput://data'; |
||
| 552 | } else { |
||
| 553 | $stream = 'php://input'; |
||
| 554 | } |
||
| 555 | |||
| 556 | return new Request( |
||
| 557 | [ |
||
| 558 | 'get' => $_GET, |
||
| 559 | 'post' => $_POST, |
||
| 560 | 'files' => $_FILES, |
||
| 561 | 'server' => $_SERVER, |
||
| 562 | 'env' => $_ENV, |
||
| 563 | 'cookies' => $_COOKIE, |
||
| 564 | 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
||
| 565 | ? $_SERVER['REQUEST_METHOD'] |
||
| 566 | : null, |
||
| 567 | 'urlParams' => $urlParams, |
||
| 568 | ], |
||
| 569 | $this->getSecureRandom(), |
||
| 570 | $this->getConfig(), |
||
| 571 | $this->getCsrfTokenManager(), |
||
| 572 | $stream |
||
| 573 | ); |
||
| 574 | }); |
||
| 575 | $this->registerService('Mailer', function (Server $c) { |
||
| 576 | return new Mailer( |
||
| 577 | $c->getConfig(), |
||
| 578 | $c->getLogger(), |
||
| 579 | $c->getThemingDefaults() |
||
| 580 | ); |
||
| 581 | }); |
||
| 582 | $this->registerService('OcsClient', function (Server $c) { |
||
| 583 | return new OCSClient( |
||
| 584 | $this->getHTTPClientService(), |
||
| 585 | $this->getConfig(), |
||
| 586 | $this->getLogger() |
||
| 587 | ); |
||
| 588 | }); |
||
| 589 | $this->registerService('LDAPProvider', function(Server $c) { |
||
| 590 | $config = $c->getConfig(); |
||
| 591 | $factoryClass = $config->getSystemValue('ldapProviderFactory', null); |
||
| 592 | if(is_null($factoryClass)) { |
||
| 593 | throw new \Exception('ldapProviderFactory not set'); |
||
| 594 | } |
||
| 595 | /** @var \OCP\LDAP\ILDAPProviderFactory $factory */ |
||
| 596 | $factory = new $factoryClass($this); |
||
| 597 | return $factory->getLDAPProvider(); |
||
| 598 | }); |
||
| 599 | $this->registerService('LockingProvider', function (Server $c) { |
||
| 600 | $ini = $c->getIniWrapper(); |
||
| 601 | $config = $c->getConfig(); |
||
| 602 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
||
| 603 | if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
||
| 604 | /** @var \OC\Memcache\Factory $memcacheFactory */ |
||
| 605 | $memcacheFactory = $c->getMemCacheFactory(); |
||
| 606 | $memcache = $memcacheFactory->createLocking('lock'); |
||
| 607 | if (!($memcache instanceof \OC\Memcache\NullCache)) { |
||
| 608 | return new MemcacheLockingProvider($memcache, $ttl); |
||
| 609 | } |
||
| 610 | return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
||
| 611 | } |
||
| 612 | return new NoopLockingProvider(); |
||
| 613 | }); |
||
| 614 | $this->registerService('MountManager', function () { |
||
| 615 | return new \OC\Files\Mount\Manager(); |
||
| 616 | }); |
||
| 617 | $this->registerService('MimeTypeDetector', function (Server $c) { |
||
| 618 | return new \OC\Files\Type\Detection( |
||
| 619 | $c->getURLGenerator(), |
||
| 620 | \OC::$configDir, |
||
| 621 | \OC::$SERVERROOT . '/resources/config/' |
||
| 622 | ); |
||
| 623 | }); |
||
| 624 | $this->registerService('MimeTypeLoader', function (Server $c) { |
||
| 625 | return new \OC\Files\Type\Loader( |
||
| 626 | $c->getDatabaseConnection() |
||
| 627 | ); |
||
| 628 | }); |
||
| 629 | $this->registerService('NotificationManager', function () { |
||
| 630 | return new Manager(); |
||
| 631 | }); |
||
| 632 | $this->registerService('CapabilitiesManager', function (Server $c) { |
||
| 633 | $manager = new \OC\CapabilitiesManager($c->getLogger()); |
||
| 634 | $manager->registerCapability(function () use ($c) { |
||
| 635 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
||
| 636 | }); |
||
| 637 | return $manager; |
||
| 638 | }); |
||
| 639 | View Code Duplication | $this->registerService('CommentsManager', function(Server $c) { |
|
| 640 | $config = $c->getConfig(); |
||
| 641 | $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
||
| 642 | /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
||
| 643 | $factory = new $factoryClass($this); |
||
| 644 | return $factory->getManager(); |
||
| 645 | }); |
||
| 646 | $this->registerService('ThemingDefaults', function(Server $c) { |
||
| 647 | /* |
||
| 648 | * Dark magic for autoloader. |
||
| 649 | * If we do a class_exists it will try to load the class which will |
||
| 650 | * make composer cache the result. Resulting in errors when enabling |
||
| 651 | * the theming app. |
||
| 652 | */ |
||
| 653 | $prefixes = \OC::$composerAutoloader->getPrefixesPsr4(); |
||
| 654 | if (isset($prefixes['OCA\\Theming\\'])) { |
||
| 655 | $classExists = true; |
||
| 656 | } else { |
||
| 657 | $classExists = false; |
||
| 658 | } |
||
| 659 | |||
| 660 | if ($classExists && $c->getConfig()->getSystemValue('installed', false) && $c->getAppManager()->isInstalled('theming')) { |
||
| 661 | return new ThemingDefaults( |
||
| 662 | $c->getConfig(), |
||
| 663 | $c->getL10N('theming'), |
||
| 664 | $c->getURLGenerator(), |
||
| 665 | new \OC_Defaults(), |
||
| 666 | $c->getLazyRootFolder() |
||
| 667 | ); |
||
| 668 | } |
||
| 669 | return new \OC_Defaults(); |
||
| 670 | }); |
||
| 671 | $this->registerService('EventDispatcher', function () { |
||
| 672 | return new EventDispatcher(); |
||
| 673 | }); |
||
| 674 | $this->registerService('CryptoWrapper', function (Server $c) { |
||
| 675 | // FIXME: Instantiiated here due to cyclic dependency |
||
| 676 | $request = new Request( |
||
| 677 | [ |
||
| 678 | 'get' => $_GET, |
||
| 679 | 'post' => $_POST, |
||
| 680 | 'files' => $_FILES, |
||
| 681 | 'server' => $_SERVER, |
||
| 682 | 'env' => $_ENV, |
||
| 683 | 'cookies' => $_COOKIE, |
||
| 684 | 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
||
| 685 | ? $_SERVER['REQUEST_METHOD'] |
||
| 686 | : null, |
||
| 687 | ], |
||
| 688 | $c->getSecureRandom(), |
||
| 689 | $c->getConfig() |
||
| 690 | ); |
||
| 691 | |||
| 692 | return new CryptoWrapper( |
||
| 693 | $c->getConfig(), |
||
| 694 | $c->getCrypto(), |
||
| 695 | $c->getSecureRandom(), |
||
| 696 | $request |
||
| 697 | ); |
||
| 698 | }); |
||
| 699 | $this->registerService('CsrfTokenManager', function (Server $c) { |
||
| 700 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
||
| 701 | $sessionStorage = new SessionStorage($c->getSession()); |
||
| 702 | |||
| 703 | return new CsrfTokenManager( |
||
| 704 | $tokenGenerator, |
||
| 705 | $sessionStorage |
||
| 706 | ); |
||
| 707 | }); |
||
| 708 | $this->registerService('ContentSecurityPolicyManager', function (Server $c) { |
||
| 709 | return new ContentSecurityPolicyManager(); |
||
| 710 | }); |
||
| 711 | $this->registerService('ShareManager', function(Server $c) { |
||
| 712 | $config = $c->getConfig(); |
||
| 713 | $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
||
| 714 | /** @var \OCP\Share\IProviderFactory $factory */ |
||
| 715 | $factory = new $factoryClass($this); |
||
| 716 | |||
| 717 | $manager = new \OC\Share20\Manager( |
||
| 718 | $c->getLogger(), |
||
| 719 | $c->getConfig(), |
||
| 720 | $c->getSecureRandom(), |
||
| 721 | $c->getHasher(), |
||
| 722 | $c->getMountManager(), |
||
| 723 | $c->getGroupManager(), |
||
| 724 | $c->getL10N('core'), |
||
| 725 | $factory, |
||
| 726 | $c->getUserManager(), |
||
| 727 | $c->getLazyRootFolder(), |
||
| 728 | $c->getEventDispatcher() |
||
| 729 | ); |
||
| 730 | |||
| 731 | return $manager; |
||
| 732 | }); |
||
| 733 | $this->registerService('SettingsManager', function(Server $c) { |
||
| 734 | $manager = new \OC\Settings\Manager( |
||
| 735 | $c->getLogger(), |
||
| 736 | $c->getDatabaseConnection(), |
||
| 737 | $c->getL10N('core'), |
||
| 738 | $c->getConfig(), |
||
| 739 | $c->getEncryptionManager(), |
||
| 740 | $c->getUserManager(), |
||
| 741 | $c->getLockingProvider() |
||
| 742 | ); |
||
| 743 | return $manager; |
||
| 744 | }); |
||
| 745 | $this->registerService(\OC\Files\AppData\Factory::class, function (Server $c) { |
||
| 746 | return new \OC\Files\AppData\Factory( |
||
| 747 | $c->getRootFolder(), |
||
| 748 | $c->getSystemConfig() |
||
| 749 | ); |
||
| 750 | }); |
||
| 751 | } |
||
| 752 | |||
| 753 | /** |
||
| 754 | * @return \OCP\Contacts\IManager |
||
| 755 | */ |
||
| 756 | public function getContactsManager() { |
||
| 759 | |||
| 760 | /** |
||
| 761 | * @return \OC\Encryption\Manager |
||
| 762 | */ |
||
| 763 | public function getEncryptionManager() { |
||
| 766 | |||
| 767 | /** |
||
| 768 | * @return \OC\Encryption\File |
||
| 769 | */ |
||
| 770 | public function getEncryptionFilesHelper() { |
||
| 773 | |||
| 774 | /** |
||
| 775 | * @return \OCP\Encryption\Keys\IStorage |
||
| 776 | */ |
||
| 777 | public function getEncryptionKeyStorage() { |
||
| 780 | |||
| 781 | /** |
||
| 782 | * The current request object holding all information about the request |
||
| 783 | * currently being processed is returned from this method. |
||
| 784 | * In case the current execution was not initiated by a web request null is returned |
||
| 785 | * |
||
| 786 | * @return \OCP\IRequest |
||
| 787 | */ |
||
| 788 | public function getRequest() { |
||
| 791 | |||
| 792 | /** |
||
| 793 | * Returns the preview manager which can create preview images for a given file |
||
| 794 | * |
||
| 795 | * @return \OCP\IPreview |
||
| 796 | */ |
||
| 797 | public function getPreviewManager() { |
||
| 800 | |||
| 801 | /** |
||
| 802 | * Returns the tag manager which can get and set tags for different object types |
||
| 803 | * |
||
| 804 | * @see \OCP\ITagManager::load() |
||
| 805 | * @return \OCP\ITagManager |
||
| 806 | */ |
||
| 807 | public function getTagManager() { |
||
| 810 | |||
| 811 | /** |
||
| 812 | * Returns the system-tag manager |
||
| 813 | * |
||
| 814 | * @return \OCP\SystemTag\ISystemTagManager |
||
| 815 | * |
||
| 816 | * @since 9.0.0 |
||
| 817 | */ |
||
| 818 | public function getSystemTagManager() { |
||
| 821 | |||
| 822 | /** |
||
| 823 | * Returns the system-tag object mapper |
||
| 824 | * |
||
| 825 | * @return \OCP\SystemTag\ISystemTagObjectMapper |
||
| 826 | * |
||
| 827 | * @since 9.0.0 |
||
| 828 | */ |
||
| 829 | public function getSystemTagObjectMapper() { |
||
| 832 | |||
| 833 | |||
| 834 | /** |
||
| 835 | * Returns the avatar manager, used for avatar functionality |
||
| 836 | * |
||
| 837 | * @return \OCP\IAvatarManager |
||
| 838 | */ |
||
| 839 | public function getAvatarManager() { |
||
| 842 | |||
| 843 | /** |
||
| 844 | * Returns the root folder of ownCloud's data directory |
||
| 845 | * |
||
| 846 | * @return \OCP\Files\IRootFolder |
||
| 847 | */ |
||
| 848 | public function getRootFolder() { |
||
| 851 | |||
| 852 | /** |
||
| 853 | * Returns the root folder of ownCloud's data directory |
||
| 854 | * This is the lazy variant so this gets only initialized once it |
||
| 855 | * is actually used. |
||
| 856 | * |
||
| 857 | * @return \OCP\Files\IRootFolder |
||
| 858 | */ |
||
| 859 | public function getLazyRootFolder() { |
||
| 862 | |||
| 863 | /** |
||
| 864 | * Returns a view to ownCloud's files folder |
||
| 865 | * |
||
| 866 | * @param string $userId user ID |
||
| 867 | * @return \OCP\Files\Folder|null |
||
| 868 | */ |
||
| 869 | public function getUserFolder($userId = null) { |
||
| 880 | |||
| 881 | /** |
||
| 882 | * Returns an app-specific view in ownClouds data directory |
||
| 883 | * |
||
| 884 | * @return \OCP\Files\Folder |
||
| 885 | * @deprecated since 9.2.0 use IAppData |
||
| 886 | */ |
||
| 887 | public function getAppFolder() { |
||
| 897 | |||
| 898 | /** |
||
| 899 | * @return \OC\User\Manager |
||
| 900 | */ |
||
| 901 | public function getUserManager() { |
||
| 904 | |||
| 905 | /** |
||
| 906 | * @return \OC\Group\Manager |
||
| 907 | */ |
||
| 908 | public function getGroupManager() { |
||
| 911 | |||
| 912 | /** |
||
| 913 | * @return \OC\User\Session |
||
| 914 | */ |
||
| 915 | public function getUserSession() { |
||
| 918 | |||
| 919 | /** |
||
| 920 | * @return \OCP\ISession |
||
| 921 | */ |
||
| 922 | public function getSession() { |
||
| 925 | |||
| 926 | /** |
||
| 927 | * @param \OCP\ISession $session |
||
| 928 | */ |
||
| 929 | public function setSession(\OCP\ISession $session) { |
||
| 932 | |||
| 933 | /** |
||
| 934 | * @return \OC\Authentication\TwoFactorAuth\Manager |
||
| 935 | */ |
||
| 936 | public function getTwoFactorAuthManager() { |
||
| 939 | |||
| 940 | /** |
||
| 941 | * @return \OC\NavigationManager |
||
| 942 | */ |
||
| 943 | public function getNavigationManager() { |
||
| 946 | |||
| 947 | /** |
||
| 948 | * @return \OCP\IConfig |
||
| 949 | */ |
||
| 950 | public function getConfig() { |
||
| 953 | |||
| 954 | /** |
||
| 955 | * @internal For internal use only |
||
| 956 | * @return \OC\SystemConfig |
||
| 957 | */ |
||
| 958 | public function getSystemConfig() { |
||
| 961 | |||
| 962 | /** |
||
| 963 | * Returns the app config manager |
||
| 964 | * |
||
| 965 | * @return \OCP\IAppConfig |
||
| 966 | */ |
||
| 967 | public function getAppConfig() { |
||
| 970 | |||
| 971 | /** |
||
| 972 | * @return \OCP\L10N\IFactory |
||
| 973 | */ |
||
| 974 | public function getL10NFactory() { |
||
| 977 | |||
| 978 | /** |
||
| 979 | * get an L10N instance |
||
| 980 | * |
||
| 981 | * @param string $app appid |
||
| 982 | * @param string $lang |
||
| 983 | * @return IL10N |
||
| 984 | */ |
||
| 985 | public function getL10N($app, $lang = null) { |
||
| 988 | |||
| 989 | /** |
||
| 990 | * @return \OCP\IURLGenerator |
||
| 991 | */ |
||
| 992 | public function getURLGenerator() { |
||
| 995 | |||
| 996 | /** |
||
| 997 | * @return \OCP\IHelper |
||
| 998 | */ |
||
| 999 | public function getHelper() { |
||
| 1002 | |||
| 1003 | /** |
||
| 1004 | * Returns an ICache instance. Since 8.1.0 it returns a fake cache. Use |
||
| 1005 | * getMemCacheFactory() instead. |
||
| 1006 | * |
||
| 1007 | * @return \OCP\ICache |
||
| 1008 | * @deprecated 8.1.0 use getMemCacheFactory to obtain a proper cache |
||
| 1009 | */ |
||
| 1010 | public function getCache() { |
||
| 1013 | |||
| 1014 | /** |
||
| 1015 | * Returns an \OCP\CacheFactory instance |
||
| 1016 | * |
||
| 1017 | * @return \OCP\ICacheFactory |
||
| 1018 | */ |
||
| 1019 | public function getMemCacheFactory() { |
||
| 1022 | |||
| 1023 | /** |
||
| 1024 | * Returns an \OC\RedisFactory instance |
||
| 1025 | * |
||
| 1026 | * @return \OC\RedisFactory |
||
| 1027 | */ |
||
| 1028 | public function getGetRedisFactory() { |
||
| 1031 | |||
| 1032 | |||
| 1033 | /** |
||
| 1034 | * Returns the current session |
||
| 1035 | * |
||
| 1036 | * @return \OCP\IDBConnection |
||
| 1037 | */ |
||
| 1038 | public function getDatabaseConnection() { |
||
| 1041 | |||
| 1042 | /** |
||
| 1043 | * Returns the activity manager |
||
| 1044 | * |
||
| 1045 | * @return \OCP\Activity\IManager |
||
| 1046 | */ |
||
| 1047 | public function getActivityManager() { |
||
| 1050 | |||
| 1051 | /** |
||
| 1052 | * Returns an job list for controlling background jobs |
||
| 1053 | * |
||
| 1054 | * @return \OCP\BackgroundJob\IJobList |
||
| 1055 | */ |
||
| 1056 | public function getJobList() { |
||
| 1059 | |||
| 1060 | /** |
||
| 1061 | * Returns a logger instance |
||
| 1062 | * |
||
| 1063 | * @return \OCP\ILogger |
||
| 1064 | */ |
||
| 1065 | public function getLogger() { |
||
| 1068 | |||
| 1069 | /** |
||
| 1070 | * Returns a router for generating and matching urls |
||
| 1071 | * |
||
| 1072 | * @return \OCP\Route\IRouter |
||
| 1073 | */ |
||
| 1074 | public function getRouter() { |
||
| 1077 | |||
| 1078 | /** |
||
| 1079 | * Returns a search instance |
||
| 1080 | * |
||
| 1081 | * @return \OCP\ISearch |
||
| 1082 | */ |
||
| 1083 | public function getSearch() { |
||
| 1086 | |||
| 1087 | /** |
||
| 1088 | * Returns a SecureRandom instance |
||
| 1089 | * |
||
| 1090 | * @return \OCP\Security\ISecureRandom |
||
| 1091 | */ |
||
| 1092 | public function getSecureRandom() { |
||
| 1095 | |||
| 1096 | /** |
||
| 1097 | * Returns a Crypto instance |
||
| 1098 | * |
||
| 1099 | * @return \OCP\Security\ICrypto |
||
| 1100 | */ |
||
| 1101 | public function getCrypto() { |
||
| 1104 | |||
| 1105 | /** |
||
| 1106 | * Returns a Hasher instance |
||
| 1107 | * |
||
| 1108 | * @return \OCP\Security\IHasher |
||
| 1109 | */ |
||
| 1110 | public function getHasher() { |
||
| 1113 | |||
| 1114 | /** |
||
| 1115 | * Returns a CredentialsManager instance |
||
| 1116 | * |
||
| 1117 | * @return \OCP\Security\ICredentialsManager |
||
| 1118 | */ |
||
| 1119 | public function getCredentialsManager() { |
||
| 1122 | |||
| 1123 | /** |
||
| 1124 | * Returns an instance of the db facade |
||
| 1125 | * |
||
| 1126 | * @deprecated use getDatabaseConnection, will be removed in ownCloud 10 |
||
| 1127 | * @return \OCP\IDb |
||
| 1128 | */ |
||
| 1129 | public function getDb() { |
||
| 1132 | |||
| 1133 | /** |
||
| 1134 | * Returns an instance of the HTTP helper class |
||
| 1135 | * |
||
| 1136 | * @deprecated Use getHTTPClientService() |
||
| 1137 | * @return \OC\HTTPHelper |
||
| 1138 | */ |
||
| 1139 | public function getHTTPHelper() { |
||
| 1142 | |||
| 1143 | /** |
||
| 1144 | * Get the certificate manager for the user |
||
| 1145 | * |
||
| 1146 | * @param string $userId (optional) if not specified the current loggedin user is used, use null to get the system certificate manager |
||
| 1147 | * @return \OCP\ICertificateManager | null if $uid is null and no user is logged in |
||
| 1148 | */ |
||
| 1149 | public function getCertificateManager($userId = '') { |
||
| 1160 | |||
| 1161 | /** |
||
| 1162 | * Returns an instance of the HTTP client service |
||
| 1163 | * |
||
| 1164 | * @return \OCP\Http\Client\IClientService |
||
| 1165 | */ |
||
| 1166 | public function getHTTPClientService() { |
||
| 1169 | |||
| 1170 | /** |
||
| 1171 | * Create a new event source |
||
| 1172 | * |
||
| 1173 | * @return \OCP\IEventSource |
||
| 1174 | */ |
||
| 1175 | public function createEventSource() { |
||
| 1178 | |||
| 1179 | /** |
||
| 1180 | * Get the active event logger |
||
| 1181 | * |
||
| 1182 | * The returned logger only logs data when debug mode is enabled |
||
| 1183 | * |
||
| 1184 | * @return \OCP\Diagnostics\IEventLogger |
||
| 1185 | */ |
||
| 1186 | public function getEventLogger() { |
||
| 1189 | |||
| 1190 | /** |
||
| 1191 | * Get the active query logger |
||
| 1192 | * |
||
| 1193 | * The returned logger only logs data when debug mode is enabled |
||
| 1194 | * |
||
| 1195 | * @return \OCP\Diagnostics\IQueryLogger |
||
| 1196 | */ |
||
| 1197 | public function getQueryLogger() { |
||
| 1200 | |||
| 1201 | /** |
||
| 1202 | * Get the manager for temporary files and folders |
||
| 1203 | * |
||
| 1204 | * @return \OCP\ITempManager |
||
| 1205 | */ |
||
| 1206 | public function getTempManager() { |
||
| 1209 | |||
| 1210 | /** |
||
| 1211 | * Get the app manager |
||
| 1212 | * |
||
| 1213 | * @return \OCP\App\IAppManager |
||
| 1214 | */ |
||
| 1215 | public function getAppManager() { |
||
| 1218 | |||
| 1219 | /** |
||
| 1220 | * Creates a new mailer |
||
| 1221 | * |
||
| 1222 | * @return \OCP\Mail\IMailer |
||
| 1223 | */ |
||
| 1224 | public function getMailer() { |
||
| 1227 | |||
| 1228 | /** |
||
| 1229 | * Get the webroot |
||
| 1230 | * |
||
| 1231 | * @return string |
||
| 1232 | */ |
||
| 1233 | public function getWebRoot() { |
||
| 1236 | |||
| 1237 | /** |
||
| 1238 | * @return \OC\OCSClient |
||
| 1239 | */ |
||
| 1240 | public function getOcsClient() { |
||
| 1243 | |||
| 1244 | /** |
||
| 1245 | * @return \OCP\IDateTimeZone |
||
| 1246 | */ |
||
| 1247 | public function getDateTimeZone() { |
||
| 1250 | |||
| 1251 | /** |
||
| 1252 | * @return \OCP\IDateTimeFormatter |
||
| 1253 | */ |
||
| 1254 | public function getDateTimeFormatter() { |
||
| 1257 | |||
| 1258 | /** |
||
| 1259 | * @return \OCP\Files\Config\IMountProviderCollection |
||
| 1260 | */ |
||
| 1261 | public function getMountProviderCollection() { |
||
| 1264 | |||
| 1265 | /** |
||
| 1266 | * Get the IniWrapper |
||
| 1267 | * |
||
| 1268 | * @return IniGetWrapper |
||
| 1269 | */ |
||
| 1270 | public function getIniWrapper() { |
||
| 1273 | |||
| 1274 | /** |
||
| 1275 | * @return \OCP\Command\IBus |
||
| 1276 | */ |
||
| 1277 | public function getCommandBus() { |
||
| 1280 | |||
| 1281 | /** |
||
| 1282 | * Get the trusted domain helper |
||
| 1283 | * |
||
| 1284 | * @return TrustedDomainHelper |
||
| 1285 | */ |
||
| 1286 | public function getTrustedDomainHelper() { |
||
| 1289 | |||
| 1290 | /** |
||
| 1291 | * Get the locking provider |
||
| 1292 | * |
||
| 1293 | * @return \OCP\Lock\ILockingProvider |
||
| 1294 | * @since 8.1.0 |
||
| 1295 | */ |
||
| 1296 | public function getLockingProvider() { |
||
| 1299 | |||
| 1300 | /** |
||
| 1301 | * @return \OCP\Files\Mount\IMountManager |
||
| 1302 | **/ |
||
| 1303 | function getMountManager() { |
||
| 1306 | |||
| 1307 | /** @return \OCP\Files\Config\IUserMountCache */ |
||
| 1308 | function getUserMountCache() { |
||
| 1311 | |||
| 1312 | /** |
||
| 1313 | * Get the MimeTypeDetector |
||
| 1314 | * |
||
| 1315 | * @return \OCP\Files\IMimeTypeDetector |
||
| 1316 | */ |
||
| 1317 | public function getMimeTypeDetector() { |
||
| 1320 | |||
| 1321 | /** |
||
| 1322 | * Get the MimeTypeLoader |
||
| 1323 | * |
||
| 1324 | * @return \OCP\Files\IMimeTypeLoader |
||
| 1325 | */ |
||
| 1326 | public function getMimeTypeLoader() { |
||
| 1329 | |||
| 1330 | /** |
||
| 1331 | * Get the manager of all the capabilities |
||
| 1332 | * |
||
| 1333 | * @return \OC\CapabilitiesManager |
||
| 1334 | */ |
||
| 1335 | public function getCapabilitiesManager() { |
||
| 1338 | |||
| 1339 | /** |
||
| 1340 | * Get the EventDispatcher |
||
| 1341 | * |
||
| 1342 | * @return EventDispatcherInterface |
||
| 1343 | * @since 8.2.0 |
||
| 1344 | */ |
||
| 1345 | public function getEventDispatcher() { |
||
| 1348 | |||
| 1349 | /** |
||
| 1350 | * Get the Notification Manager |
||
| 1351 | * |
||
| 1352 | * @return \OCP\Notification\IManager |
||
| 1353 | * @since 8.2.0 |
||
| 1354 | */ |
||
| 1355 | public function getNotificationManager() { |
||
| 1358 | |||
| 1359 | /** |
||
| 1360 | * @return \OCP\Comments\ICommentsManager |
||
| 1361 | */ |
||
| 1362 | public function getCommentsManager() { |
||
| 1365 | |||
| 1366 | /** |
||
| 1367 | * @return \OC_Defaults |
||
| 1368 | */ |
||
| 1369 | public function getThemingDefaults() { |
||
| 1372 | |||
| 1373 | /** |
||
| 1374 | * @return \OC\IntegrityCheck\Checker |
||
| 1375 | */ |
||
| 1376 | public function getIntegrityCodeChecker() { |
||
| 1379 | |||
| 1380 | /** |
||
| 1381 | * @return \OC\Session\CryptoWrapper |
||
| 1382 | */ |
||
| 1383 | public function getSessionCryptoWrapper() { |
||
| 1386 | |||
| 1387 | /** |
||
| 1388 | * @return CsrfTokenManager |
||
| 1389 | */ |
||
| 1390 | public function getCsrfTokenManager() { |
||
| 1393 | |||
| 1394 | /** |
||
| 1395 | * @return Throttler |
||
| 1396 | */ |
||
| 1397 | public function getBruteForceThrottler() { |
||
| 1400 | |||
| 1401 | /** |
||
| 1402 | * @return IContentSecurityPolicyManager |
||
| 1403 | */ |
||
| 1404 | public function getContentSecurityPolicyManager() { |
||
| 1407 | |||
| 1408 | /** |
||
| 1409 | * Not a public API as of 8.2, wait for 9.0 |
||
| 1410 | * |
||
| 1411 | * @return \OCA\Files_External\Service\BackendService |
||
| 1412 | */ |
||
| 1413 | public function getStoragesBackendService() { |
||
| 1416 | |||
| 1417 | /** |
||
| 1418 | * Not a public API as of 8.2, wait for 9.0 |
||
| 1419 | * |
||
| 1420 | * @return \OCA\Files_External\Service\GlobalStoragesService |
||
| 1421 | */ |
||
| 1422 | public function getGlobalStoragesService() { |
||
| 1425 | |||
| 1426 | /** |
||
| 1427 | * Not a public API as of 8.2, wait for 9.0 |
||
| 1428 | * |
||
| 1429 | * @return \OCA\Files_External\Service\UserGlobalStoragesService |
||
| 1430 | */ |
||
| 1431 | public function getUserGlobalStoragesService() { |
||
| 1434 | |||
| 1435 | /** |
||
| 1436 | * Not a public API as of 8.2, wait for 9.0 |
||
| 1437 | * |
||
| 1438 | * @return \OCA\Files_External\Service\UserStoragesService |
||
| 1439 | */ |
||
| 1440 | public function getUserStoragesService() { |
||
| 1443 | |||
| 1444 | /** |
||
| 1445 | * @return \OCP\Share\IManager |
||
| 1446 | */ |
||
| 1447 | public function getShareManager() { |
||
| 1450 | |||
| 1451 | /** |
||
| 1452 | * Returns the LDAP Provider |
||
| 1453 | * |
||
| 1454 | * @return \OCP\LDAP\ILDAPProvider |
||
| 1455 | */ |
||
| 1456 | public function getLDAPProvider() { |
||
| 1459 | |||
| 1460 | /** |
||
| 1461 | * @return \OCP\Settings\IManager |
||
| 1462 | */ |
||
| 1463 | public function getSettingsManager() { |
||
| 1466 | |||
| 1467 | /** |
||
| 1468 | * @return \OCP\Files\IAppData |
||
| 1469 | */ |
||
| 1470 | public function getAppDataDir($app) { |
||
| 1475 | } |
||
| 1476 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.