| Conditions | 8 |
| Paths | 7 |
| Total Lines | 54 |
| Code Lines | 27 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
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 |
||
| 69 | public function runRegistration(): void { |
||
| 70 | if ($this->registrationContext !== null) { |
||
| 71 | throw new RuntimeException('Registration has already been run'); |
||
| 72 | } |
||
| 73 | |||
| 74 | $this->registrationContext = new RegistrationContext($this->logger); |
||
| 75 | $apps = []; |
||
| 76 | foreach (OC_App::getEnabledApps() as $appId) { |
||
| 77 | /* |
||
| 78 | * First, we have to enable the app's autoloader |
||
| 79 | * |
||
| 80 | * @todo use $this->appManager->getAppPath($appId) here |
||
| 81 | */ |
||
| 82 | $path = OC_App::getAppPath($appId); |
||
|
|
|||
| 83 | if ($path === false) { |
||
| 84 | // Ignore |
||
| 85 | continue; |
||
| 86 | } |
||
| 87 | OC_App::registerAutoloading($appId, $path); |
||
| 88 | |||
| 89 | /* |
||
| 90 | * Next we check if there is an application class and it implements |
||
| 91 | * the \OCP\AppFramework\Bootstrap\IBootstrap interface |
||
| 92 | */ |
||
| 93 | $appNameSpace = App::buildAppNamespace($appId); |
||
| 94 | $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
||
| 95 | if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { |
||
| 96 | try { |
||
| 97 | /** @var IBootstrap|App $application */ |
||
| 98 | $apps[$appId] = $application = $this->serverContainer->query($applicationClassName); |
||
| 99 | } catch (QueryException $e) { |
||
| 100 | // Weird, but ok |
||
| 101 | continue; |
||
| 102 | } |
||
| 103 | try { |
||
| 104 | $application->register($this->registrationContext->for($appId)); |
||
| 105 | } catch (Throwable $e) { |
||
| 106 | $this->logger->logException($e, [ |
||
| 107 | 'message' => 'Error during app service registration: ' . $e->getMessage(), |
||
| 108 | 'level' => ILogger::FATAL, |
||
| 109 | ]); |
||
| 110 | } |
||
| 111 | } |
||
| 112 | } |
||
| 113 | |||
| 114 | /** |
||
| 115 | * Now that all register methods have been called, we can delegate the registrations |
||
| 116 | * to the actual services |
||
| 117 | */ |
||
| 118 | $this->registrationContext->delegateCapabilityRegistrations($apps); |
||
| 119 | $this->registrationContext->delegateCrashReporterRegistrations($apps, $this->registry); |
||
| 120 | $this->registrationContext->delegateEventListenerRegistrations($this->eventDispatcher); |
||
| 121 | $this->registrationContext->delegateContainerRegistrations($apps); |
||
| 122 | $this->registrationContext->delegateMiddlewareRegistrations($apps); |
||
| 123 | } |
||
| 170 |
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.