| Conditions | 22 |
| Paths | 1 |
| Total Lines | 539 |
| Code Lines | 379 |
| Lines | 22 |
| Ratio | 4.08 % |
| Changes | 3 | ||
| Bugs | 1 | Features | 1 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 97 | public function __construct($webRoot, \OC\Config $config) { |
||
| 98 | parent::__construct(); |
||
| 99 | $this->webRoot = $webRoot; |
||
| 100 | |||
| 101 | $this->registerService('ContactsManager', function ($c) { |
||
|
|
|||
| 102 | return new ContactsManager(); |
||
| 103 | }); |
||
| 104 | |||
| 105 | $this->registerService('PreviewManager', function (Server $c) { |
||
| 106 | return new PreviewManager($c->getConfig()); |
||
| 107 | }); |
||
| 108 | |||
| 109 | $this->registerService('EncryptionManager', function (Server $c) { |
||
| 110 | $view = new View(); |
||
| 111 | $util = new Encryption\Util( |
||
| 112 | $view, |
||
| 113 | $c->getUserManager(), |
||
| 114 | $c->getGroupManager(), |
||
| 115 | $c->getConfig() |
||
| 116 | ); |
||
| 117 | return new Encryption\Manager( |
||
| 118 | $c->getConfig(), |
||
| 119 | $c->getLogger(), |
||
| 120 | $c->getL10N('core'), |
||
| 121 | new View(), |
||
| 122 | $util, |
||
| 123 | new ArrayCache() |
||
| 124 | ); |
||
| 125 | }); |
||
| 126 | |||
| 127 | $this->registerService('EncryptionFileHelper', function (Server $c) { |
||
| 128 | $util = new Encryption\Util( |
||
| 129 | new View(), |
||
| 130 | $c->getUserManager(), |
||
| 131 | $c->getGroupManager(), |
||
| 132 | $c->getConfig() |
||
| 133 | ); |
||
| 134 | return new Encryption\File($util); |
||
| 135 | }); |
||
| 136 | |||
| 137 | $this->registerService('EncryptionKeyStorage', function (Server $c) { |
||
| 138 | $view = new View(); |
||
| 139 | $util = new Encryption\Util( |
||
| 140 | $view, |
||
| 141 | $c->getUserManager(), |
||
| 142 | $c->getGroupManager(), |
||
| 143 | $c->getConfig() |
||
| 144 | ); |
||
| 145 | |||
| 146 | return new Encryption\Keys\Storage($view, $util); |
||
| 147 | }); |
||
| 148 | $this->registerService('TagMapper', function (Server $c) { |
||
| 149 | return new TagMapper($c->getDatabaseConnection()); |
||
| 150 | }); |
||
| 151 | $this->registerService('TagManager', function (Server $c) { |
||
| 152 | $tagMapper = $c->query('TagMapper'); |
||
| 153 | return new TagManager($tagMapper, $c->getUserSession()); |
||
| 154 | }); |
||
| 155 | View Code Duplication | $this->registerService('SystemTagManagerFactory', function (Server $c) { |
|
| 156 | $config = $c->getConfig(); |
||
| 157 | $factoryClass = $config->getSystemValue('systemtags.managerFactory', '\OC\SystemTag\ManagerFactory'); |
||
| 158 | /** @var \OC\SystemTag\ManagerFactory $factory */ |
||
| 159 | $factory = new $factoryClass($this); |
||
| 160 | return $factory; |
||
| 161 | }); |
||
| 162 | $this->registerService('SystemTagManager', function (Server $c) { |
||
| 163 | return $c->query('SystemTagManagerFactory')->getManager(); |
||
| 164 | }); |
||
| 165 | $this->registerService('SystemTagObjectMapper', function (Server $c) { |
||
| 166 | return $c->query('SystemTagManagerFactory')->getObjectMapper(); |
||
| 167 | }); |
||
| 168 | $this->registerService('RootFolder', function () { |
||
| 169 | $manager = \OC\Files\Filesystem::getMountManager(null); |
||
| 170 | $view = new View(); |
||
| 171 | $root = new Root($manager, $view, null); |
||
| 172 | $connector = new HookConnector($root, $view); |
||
| 173 | $connector->viewToNode(); |
||
| 174 | return $root; |
||
| 175 | }); |
||
| 176 | $this->registerService('LazyRootFolder', function(Server $c) { |
||
| 177 | return new LazyRoot(function() use ($c) { |
||
| 178 | return $c->getRootFolder(); |
||
| 179 | }); |
||
| 180 | }); |
||
| 181 | $this->registerService('UserManager', function (Server $c) { |
||
| 182 | $config = $c->getConfig(); |
||
| 183 | return new \OC\User\Manager($config); |
||
| 184 | }); |
||
| 185 | $this->registerService('GroupManager', function (Server $c) { |
||
| 186 | $groupManager = new \OC\Group\Manager($this->getUserManager()); |
||
| 187 | $groupManager->listen('\OC\Group', 'preCreate', function ($gid) { |
||
| 188 | \OC_Hook::emit('OC_Group', 'pre_createGroup', array('run' => true, 'gid' => $gid)); |
||
| 189 | }); |
||
| 190 | $groupManager->listen('\OC\Group', 'postCreate', function (\OC\Group\Group $gid) { |
||
| 191 | \OC_Hook::emit('OC_User', 'post_createGroup', array('gid' => $gid->getGID())); |
||
| 192 | }); |
||
| 193 | $groupManager->listen('\OC\Group', 'preDelete', function (\OC\Group\Group $group) { |
||
| 194 | \OC_Hook::emit('OC_Group', 'pre_deleteGroup', array('run' => true, 'gid' => $group->getGID())); |
||
| 195 | }); |
||
| 196 | $groupManager->listen('\OC\Group', 'postDelete', function (\OC\Group\Group $group) { |
||
| 197 | \OC_Hook::emit('OC_User', 'post_deleteGroup', array('gid' => $group->getGID())); |
||
| 198 | }); |
||
| 199 | $groupManager->listen('\OC\Group', 'preAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
||
| 200 | \OC_Hook::emit('OC_Group', 'pre_addToGroup', array('run' => true, 'uid' => $user->getUID(), 'gid' => $group->getGID())); |
||
| 201 | }); |
||
| 202 | $groupManager->listen('\OC\Group', 'postAddUser', function (\OC\Group\Group $group, \OC\User\User $user) { |
||
| 203 | \OC_Hook::emit('OC_Group', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
||
| 204 | //Minimal fix to keep it backward compatible TODO: clean up all the GroupManager hooks |
||
| 205 | \OC_Hook::emit('OC_User', 'post_addToGroup', array('uid' => $user->getUID(), 'gid' => $group->getGID())); |
||
| 206 | }); |
||
| 207 | return $groupManager; |
||
| 208 | }); |
||
| 209 | $this->registerService('UserSession', function (Server $c) { |
||
| 210 | $manager = $c->getUserManager(); |
||
| 211 | |||
| 212 | $session = new \OC\Session\Memory(''); |
||
| 213 | |||
| 214 | $userSession = new \OC\User\Session($manager, $session); |
||
| 215 | $userSession->listen('\OC\User', 'preCreateUser', function ($uid, $password) { |
||
| 216 | \OC_Hook::emit('OC_User', 'pre_createUser', array('run' => true, 'uid' => $uid, 'password' => $password)); |
||
| 217 | }); |
||
| 218 | $userSession->listen('\OC\User', 'postCreateUser', function ($user, $password) { |
||
| 219 | /** @var $user \OC\User\User */ |
||
| 220 | \OC_Hook::emit('OC_User', 'post_createUser', array('uid' => $user->getUID(), 'password' => $password)); |
||
| 221 | }); |
||
| 222 | $userSession->listen('\OC\User', 'preDelete', function ($user) { |
||
| 223 | /** @var $user \OC\User\User */ |
||
| 224 | \OC_Hook::emit('OC_User', 'pre_deleteUser', array('run' => true, 'uid' => $user->getUID())); |
||
| 225 | }); |
||
| 226 | $userSession->listen('\OC\User', 'postDelete', function ($user) { |
||
| 227 | /** @var $user \OC\User\User */ |
||
| 228 | \OC_Hook::emit('OC_User', 'post_deleteUser', array('uid' => $user->getUID())); |
||
| 229 | }); |
||
| 230 | View Code Duplication | $userSession->listen('\OC\User', 'preSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 231 | /** @var $user \OC\User\User */ |
||
| 232 | \OC_Hook::emit('OC_User', 'pre_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
||
| 233 | }); |
||
| 234 | View Code Duplication | $userSession->listen('\OC\User', 'postSetPassword', function ($user, $password, $recoveryPassword) { |
|
| 235 | /** @var $user \OC\User\User */ |
||
| 236 | \OC_Hook::emit('OC_User', 'post_setPassword', array('run' => true, 'uid' => $user->getUID(), 'password' => $password, 'recoveryPassword' => $recoveryPassword)); |
||
| 237 | }); |
||
| 238 | $userSession->listen('\OC\User', 'preLogin', function ($uid, $password) { |
||
| 239 | \OC_Hook::emit('OC_User', 'pre_login', array('run' => true, 'uid' => $uid, 'password' => $password)); |
||
| 240 | }); |
||
| 241 | $userSession->listen('\OC\User', 'postLogin', function ($user, $password) { |
||
| 242 | /** @var $user \OC\User\User */ |
||
| 243 | \OC_Hook::emit('OC_User', 'post_login', array('run' => true, 'uid' => $user->getUID(), 'password' => $password)); |
||
| 244 | }); |
||
| 245 | $userSession->listen('\OC\User', 'logout', function () { |
||
| 246 | \OC_Hook::emit('OC_User', 'logout', array()); |
||
| 247 | }); |
||
| 248 | $userSession->listen('\OC\User', 'changeUser', function ($user, $feature, $value) { |
||
| 249 | /** @var $user \OC\User\User */ |
||
| 250 | \OC_Hook::emit('OC_User', 'changeUser', array('run' => true, 'user' => $user, 'feature' => $feature, 'value' => $value)); |
||
| 251 | }); |
||
| 252 | return $userSession; |
||
| 253 | }); |
||
| 254 | $this->registerService('NavigationManager', function ($c) { |
||
| 255 | return new \OC\NavigationManager(); |
||
| 256 | }); |
||
| 257 | $this->registerService('AllConfig', function (Server $c) { |
||
| 258 | return new \OC\AllConfig( |
||
| 259 | $c->getSystemConfig() |
||
| 260 | ); |
||
| 261 | }); |
||
| 262 | $this->registerService('SystemConfig', function ($c) use ($config) { |
||
| 263 | return new \OC\SystemConfig($config); |
||
| 264 | }); |
||
| 265 | $this->registerService('AppConfig', function (Server $c) { |
||
| 266 | return new \OC\AppConfig($c->getDatabaseConnection()); |
||
| 267 | }); |
||
| 268 | $this->registerService('L10NFactory', function (Server $c) { |
||
| 269 | return new \OC\L10N\Factory( |
||
| 270 | $c->getConfig(), |
||
| 271 | $c->getRequest(), |
||
| 272 | $c->getUserSession(), |
||
| 273 | \OC::$SERVERROOT |
||
| 274 | ); |
||
| 275 | }); |
||
| 276 | $this->registerService('URLGenerator', function (Server $c) { |
||
| 277 | $config = $c->getConfig(); |
||
| 278 | $cacheFactory = $c->getMemCacheFactory(); |
||
| 279 | return new \OC\URLGenerator( |
||
| 280 | $config, |
||
| 281 | $cacheFactory |
||
| 282 | ); |
||
| 283 | }); |
||
| 284 | $this->registerService('AppHelper', function ($c) { |
||
| 285 | return new \OC\AppHelper(); |
||
| 286 | }); |
||
| 287 | $this->registerService('UserCache', function ($c) { |
||
| 288 | return new Cache\File(); |
||
| 289 | }); |
||
| 290 | $this->registerService('MemCacheFactory', function (Server $c) { |
||
| 291 | $config = $c->getConfig(); |
||
| 292 | |||
| 293 | if ($config->getSystemValue('installed', false) && !(defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
||
| 294 | $v = \OC_App::getAppVersions(); |
||
| 295 | $v['core'] = md5(file_get_contents(\OC::$SERVERROOT . '/version.php')); |
||
| 296 | $version = implode(',', $v); |
||
| 297 | $instanceId = \OC_Util::getInstanceId(); |
||
| 298 | $path = \OC::$SERVERROOT; |
||
| 299 | $prefix = md5($instanceId . '-' . $version . '-' . $path); |
||
| 300 | return new \OC\Memcache\Factory($prefix, $c->getLogger(), |
||
| 301 | $config->getSystemValue('memcache.local', null), |
||
| 302 | $config->getSystemValue('memcache.distributed', null), |
||
| 303 | $config->getSystemValue('memcache.locking', null) |
||
| 304 | ); |
||
| 305 | } |
||
| 306 | |||
| 307 | return new \OC\Memcache\Factory('', $c->getLogger(), |
||
| 308 | '\\OC\\Memcache\\ArrayCache', |
||
| 309 | '\\OC\\Memcache\\ArrayCache', |
||
| 310 | '\\OC\\Memcache\\ArrayCache' |
||
| 311 | ); |
||
| 312 | }); |
||
| 313 | $this->registerService('ActivityManager', function (Server $c) { |
||
| 314 | return new ActivityManager( |
||
| 315 | $c->getRequest(), |
||
| 316 | $c->getUserSession(), |
||
| 317 | $c->getConfig() |
||
| 318 | ); |
||
| 319 | }); |
||
| 320 | $this->registerService('AvatarManager', function (Server $c) { |
||
| 321 | return new AvatarManager( |
||
| 322 | $c->getUserManager(), |
||
| 323 | $c->getRootFolder(), |
||
| 324 | $c->getL10N('lib'), |
||
| 325 | $c->getLogger() |
||
| 326 | ); |
||
| 327 | }); |
||
| 328 | $this->registerService('Logger', function (Server $c) { |
||
| 329 | $logClass = $c->query('AllConfig')->getSystemValue('log_type', 'owncloud'); |
||
| 330 | $logger = 'OC_Log_' . ucfirst($logClass); |
||
| 331 | call_user_func(array($logger, 'init')); |
||
| 332 | |||
| 333 | return new Log($logger); |
||
| 334 | }); |
||
| 335 | $this->registerService('JobList', function (Server $c) { |
||
| 336 | $config = $c->getConfig(); |
||
| 337 | return new \OC\BackgroundJob\JobList($c->getDatabaseConnection(), $config); |
||
| 338 | }); |
||
| 339 | $this->registerService('Router', function (Server $c) { |
||
| 340 | $cacheFactory = $c->getMemCacheFactory(); |
||
| 341 | $logger = $c->getLogger(); |
||
| 342 | if ($cacheFactory->isAvailable()) { |
||
| 343 | $router = new \OC\Route\CachingRouter($cacheFactory->create('route'), $logger); |
||
| 344 | } else { |
||
| 345 | $router = new \OC\Route\Router($logger); |
||
| 346 | } |
||
| 347 | return $router; |
||
| 348 | }); |
||
| 349 | $this->registerService('Search', function ($c) { |
||
| 350 | return new Search(); |
||
| 351 | }); |
||
| 352 | $this->registerService('SecureRandom', function ($c) { |
||
| 353 | return new SecureRandom(); |
||
| 354 | }); |
||
| 355 | $this->registerService('Crypto', function (Server $c) { |
||
| 356 | return new Crypto($c->getConfig(), $c->getSecureRandom()); |
||
| 357 | }); |
||
| 358 | $this->registerService('Hasher', function (Server $c) { |
||
| 359 | return new Hasher($c->getConfig()); |
||
| 360 | }); |
||
| 361 | $this->registerService('CredentialsManager', function (Server $c) { |
||
| 362 | return new CredentialsManager($c->getCrypto(), $c->getDatabaseConnection()); |
||
| 363 | }); |
||
| 364 | $this->registerService('DatabaseConnection', function (Server $c) { |
||
| 365 | $factory = new \OC\DB\ConnectionFactory(); |
||
| 366 | $systemConfig = $c->getSystemConfig(); |
||
| 367 | $type = $systemConfig->getValue('dbtype', 'sqlite'); |
||
| 368 | if (!$factory->isValidType($type)) { |
||
| 369 | throw new \OC\DatabaseException('Invalid database type'); |
||
| 370 | } |
||
| 371 | $connectionParams = $factory->createConnectionParams($systemConfig); |
||
| 372 | $connection = $factory->getConnection($type, $connectionParams); |
||
| 373 | $connection->getConfiguration()->setSQLLogger($c->getQueryLogger()); |
||
| 374 | return $connection; |
||
| 375 | }); |
||
| 376 | $this->registerService('Db', function (Server $c) { |
||
| 377 | return new Db($c->getDatabaseConnection()); |
||
| 378 | }); |
||
| 379 | $this->registerService('HTTPHelper', function (Server $c) { |
||
| 380 | $config = $c->getConfig(); |
||
| 381 | return new HTTPHelper( |
||
| 382 | $config, |
||
| 383 | $c->getHTTPClientService() |
||
| 384 | ); |
||
| 385 | }); |
||
| 386 | $this->registerService('HttpClientService', function (Server $c) { |
||
| 387 | $user = \OC_User::getUser(); |
||
| 388 | $uid = $user ? $user : null; |
||
| 389 | return new ClientService( |
||
| 390 | $c->getConfig(), |
||
| 391 | new \OC\Security\CertificateManager($uid, new View(), $c->getConfig()) |
||
| 392 | ); |
||
| 393 | }); |
||
| 394 | $this->registerService('EventLogger', function (Server $c) { |
||
| 395 | if ($c->getSystemConfig()->getValue('debug', false)) { |
||
| 396 | return new EventLogger(); |
||
| 397 | } else { |
||
| 398 | return new NullEventLogger(); |
||
| 399 | } |
||
| 400 | }); |
||
| 401 | $this->registerService('QueryLogger', function (Server $c) { |
||
| 402 | if ($c->getSystemConfig()->getValue('debug', false)) { |
||
| 403 | return new QueryLogger(); |
||
| 404 | } else { |
||
| 405 | return new NullQueryLogger(); |
||
| 406 | } |
||
| 407 | }); |
||
| 408 | $this->registerService('TempManager', function (Server $c) { |
||
| 409 | return new TempManager( |
||
| 410 | $c->getLogger(), |
||
| 411 | $c->getConfig() |
||
| 412 | ); |
||
| 413 | }); |
||
| 414 | $this->registerService('AppManager', function (Server $c) { |
||
| 415 | return new \OC\App\AppManager( |
||
| 416 | $c->getUserSession(), |
||
| 417 | $c->getAppConfig(), |
||
| 418 | $c->getGroupManager(), |
||
| 419 | $c->getMemCacheFactory(), |
||
| 420 | $c->getEventDispatcher() |
||
| 421 | ); |
||
| 422 | }); |
||
| 423 | $this->registerService('DateTimeZone', function (Server $c) { |
||
| 424 | return new DateTimeZone( |
||
| 425 | $c->getConfig(), |
||
| 426 | $c->getSession() |
||
| 427 | ); |
||
| 428 | }); |
||
| 429 | $this->registerService('DateTimeFormatter', function (Server $c) { |
||
| 430 | $language = $c->getConfig()->getUserValue($c->getSession()->get('user_id'), 'core', 'lang', null); |
||
| 431 | |||
| 432 | return new DateTimeFormatter( |
||
| 433 | $c->getDateTimeZone()->getTimeZone(), |
||
| 434 | $c->getL10N('lib', $language) |
||
| 435 | ); |
||
| 436 | }); |
||
| 437 | $this->registerService('UserMountCache', function (Server $c) { |
||
| 438 | $mountCache = new UserMountCache($c->getDatabaseConnection(), $c->getUserManager(), $c->getLogger()); |
||
| 439 | $listener = new UserMountCacheListener($mountCache); |
||
| 440 | $listener->listen($c->getUserManager()); |
||
| 441 | return $mountCache; |
||
| 442 | }); |
||
| 443 | $this->registerService('MountConfigManager', function (Server $c) { |
||
| 444 | $loader = \OC\Files\Filesystem::getLoader(); |
||
| 445 | $mountCache = $c->query('UserMountCache'); |
||
| 446 | return new \OC\Files\Config\MountProviderCollection($loader, $mountCache); |
||
| 447 | }); |
||
| 448 | $this->registerService('IniWrapper', function ($c) { |
||
| 449 | return new IniGetWrapper(); |
||
| 450 | }); |
||
| 451 | $this->registerService('AsyncCommandBus', function (Server $c) { |
||
| 452 | $jobList = $c->getJobList(); |
||
| 453 | return new AsyncBus($jobList); |
||
| 454 | }); |
||
| 455 | $this->registerService('TrustedDomainHelper', function ($c) { |
||
| 456 | return new TrustedDomainHelper($this->getConfig()); |
||
| 457 | }); |
||
| 458 | $this->registerService('IntegrityCodeChecker', function (Server $c) { |
||
| 459 | // IConfig and IAppManager requires a working database. This code |
||
| 460 | // might however be called when ownCloud is not yet setup. |
||
| 461 | if(\OC::$server->getSystemConfig()->getValue('installed', false)) { |
||
| 462 | $config = $c->getConfig(); |
||
| 463 | $appManager = $c->getAppManager(); |
||
| 464 | } else { |
||
| 465 | $config = null; |
||
| 466 | $appManager = null; |
||
| 467 | } |
||
| 468 | |||
| 469 | return new Checker( |
||
| 470 | new EnvironmentHelper(), |
||
| 471 | new FileAccessHelper(), |
||
| 472 | new AppLocator(), |
||
| 473 | $config, |
||
| 474 | $c->getMemCacheFactory(), |
||
| 475 | $appManager, |
||
| 476 | $c->getTempManager() |
||
| 477 | ); |
||
| 478 | }); |
||
| 479 | $this->registerService('Request', function ($c) { |
||
| 480 | if (isset($this['urlParams'])) { |
||
| 481 | $urlParams = $this['urlParams']; |
||
| 482 | } else { |
||
| 483 | $urlParams = []; |
||
| 484 | } |
||
| 485 | |||
| 486 | if (defined('PHPUNIT_RUN') && PHPUNIT_RUN |
||
| 487 | && in_array('fakeinput', stream_get_wrappers()) |
||
| 488 | ) { |
||
| 489 | $stream = 'fakeinput://data'; |
||
| 490 | } else { |
||
| 491 | $stream = 'php://input'; |
||
| 492 | } |
||
| 493 | |||
| 494 | return new Request( |
||
| 495 | [ |
||
| 496 | 'get' => $_GET, |
||
| 497 | 'post' => $_POST, |
||
| 498 | 'files' => $_FILES, |
||
| 499 | 'server' => $_SERVER, |
||
| 500 | 'env' => $_ENV, |
||
| 501 | 'cookies' => $_COOKIE, |
||
| 502 | 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
||
| 503 | ? $_SERVER['REQUEST_METHOD'] |
||
| 504 | : null, |
||
| 505 | 'urlParams' => $urlParams, |
||
| 506 | ], |
||
| 507 | $this->getSecureRandom(), |
||
| 508 | $this->getConfig(), |
||
| 509 | $this->getCsrfTokenManager(), |
||
| 510 | $stream |
||
| 511 | ); |
||
| 512 | }); |
||
| 513 | $this->registerService('Mailer', function (Server $c) { |
||
| 514 | return new Mailer( |
||
| 515 | $c->getConfig(), |
||
| 516 | $c->getLogger(), |
||
| 517 | new \OC_Defaults() |
||
| 518 | ); |
||
| 519 | }); |
||
| 520 | $this->registerService('OcsClient', function (Server $c) { |
||
| 521 | return new OCSClient( |
||
| 522 | $this->getHTTPClientService(), |
||
| 523 | $this->getConfig(), |
||
| 524 | $this->getLogger() |
||
| 525 | ); |
||
| 526 | }); |
||
| 527 | $this->registerService('LockingProvider', function (Server $c) { |
||
| 528 | $ini = $c->getIniWrapper(); |
||
| 529 | $config = $c->getConfig(); |
||
| 530 | $ttl = $config->getSystemValue('filelocking.ttl', max(3600, $ini->getNumeric('max_execution_time'))); |
||
| 531 | if ($config->getSystemValue('filelocking.enabled', true) or (defined('PHPUNIT_RUN') && PHPUNIT_RUN)) { |
||
| 532 | /** @var \OC\Memcache\Factory $memcacheFactory */ |
||
| 533 | $memcacheFactory = $c->getMemCacheFactory(); |
||
| 534 | $memcache = $memcacheFactory->createLocking('lock'); |
||
| 535 | if (!($memcache instanceof \OC\Memcache\NullCache)) { |
||
| 536 | return new MemcacheLockingProvider($memcache, $ttl); |
||
| 537 | } |
||
| 538 | return new DBLockingProvider($c->getDatabaseConnection(), $c->getLogger(), new TimeFactory(), $ttl); |
||
| 539 | } |
||
| 540 | return new NoopLockingProvider(); |
||
| 541 | }); |
||
| 542 | $this->registerService('MountManager', function () { |
||
| 543 | return new \OC\Files\Mount\Manager(); |
||
| 544 | }); |
||
| 545 | $this->registerService('MimeTypeDetector', function (Server $c) { |
||
| 546 | return new \OC\Files\Type\Detection( |
||
| 547 | $c->getURLGenerator(), |
||
| 548 | \OC::$SERVERROOT . '/config/', |
||
| 549 | \OC::$SERVERROOT . '/resources/config/' |
||
| 550 | ); |
||
| 551 | }); |
||
| 552 | $this->registerService('MimeTypeLoader', function (Server $c) { |
||
| 553 | return new \OC\Files\Type\Loader( |
||
| 554 | $c->getDatabaseConnection() |
||
| 555 | ); |
||
| 556 | }); |
||
| 557 | $this->registerService('NotificationManager', function () { |
||
| 558 | return new Manager(); |
||
| 559 | }); |
||
| 560 | $this->registerService('CapabilitiesManager', function (Server $c) { |
||
| 561 | $manager = new \OC\CapabilitiesManager(); |
||
| 562 | $manager->registerCapability(function () use ($c) { |
||
| 563 | return new \OC\OCS\CoreCapabilities($c->getConfig()); |
||
| 564 | }); |
||
| 565 | return $manager; |
||
| 566 | }); |
||
| 567 | View Code Duplication | $this->registerService('CommentsManager', function(Server $c) { |
|
| 568 | $config = $c->getConfig(); |
||
| 569 | $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); |
||
| 570 | /** @var \OCP\Comments\ICommentsManagerFactory $factory */ |
||
| 571 | $factory = new $factoryClass($this); |
||
| 572 | return $factory->getManager(); |
||
| 573 | }); |
||
| 574 | $this->registerService('EventDispatcher', function () { |
||
| 575 | return new EventDispatcher(); |
||
| 576 | }); |
||
| 577 | $this->registerService('CryptoWrapper', function (Server $c) { |
||
| 578 | // FIXME: Instantiiated here due to cyclic dependency |
||
| 579 | $request = new Request( |
||
| 580 | [ |
||
| 581 | 'get' => $_GET, |
||
| 582 | 'post' => $_POST, |
||
| 583 | 'files' => $_FILES, |
||
| 584 | 'server' => $_SERVER, |
||
| 585 | 'env' => $_ENV, |
||
| 586 | 'cookies' => $_COOKIE, |
||
| 587 | 'method' => (isset($_SERVER) && isset($_SERVER['REQUEST_METHOD'])) |
||
| 588 | ? $_SERVER['REQUEST_METHOD'] |
||
| 589 | : null, |
||
| 590 | ], |
||
| 591 | $c->getSecureRandom(), |
||
| 592 | $c->getConfig() |
||
| 593 | ); |
||
| 594 | |||
| 595 | return new CryptoWrapper( |
||
| 596 | $c->getConfig(), |
||
| 597 | $c->getCrypto(), |
||
| 598 | $c->getSecureRandom(), |
||
| 599 | $request |
||
| 600 | ); |
||
| 601 | }); |
||
| 602 | $this->registerService('CsrfTokenManager', function (Server $c) { |
||
| 603 | $tokenGenerator = new CsrfTokenGenerator($c->getSecureRandom()); |
||
| 604 | $sessionStorage = new SessionStorage($c->getSession()); |
||
| 605 | |||
| 606 | return new CsrfTokenManager( |
||
| 607 | $tokenGenerator, |
||
| 608 | $sessionStorage |
||
| 609 | ); |
||
| 610 | }); |
||
| 611 | $this->registerService('ContentSecurityPolicyManager', function (Server $c) { |
||
| 612 | return new ContentSecurityPolicyManager(); |
||
| 613 | }); |
||
| 614 | $this->registerService('ShareManager', function(Server $c) { |
||
| 615 | $config = $c->getConfig(); |
||
| 616 | $factoryClass = $config->getSystemValue('sharing.managerFactory', '\OC\Share20\ProviderFactory'); |
||
| 617 | /** @var \OC\Share20\IProviderFactory $factory */ |
||
| 618 | $factory = new $factoryClass($this); |
||
| 619 | |||
| 620 | $manager = new \OC\Share20\Manager( |
||
| 621 | $c->getLogger(), |
||
| 622 | $c->getConfig(), |
||
| 623 | $c->getSecureRandom(), |
||
| 624 | $c->getHasher(), |
||
| 625 | $c->getMountManager(), |
||
| 626 | $c->getGroupManager(), |
||
| 627 | $c->getL10N('core'), |
||
| 628 | $factory, |
||
| 629 | $c->getUserManager(), |
||
| 630 | $c->getLazyRootFolder() |
||
| 631 | ); |
||
| 632 | |||
| 633 | return $manager; |
||
| 634 | }); |
||
| 635 | } |
||
| 636 | |||
| 1300 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.