@@ -45,153 +45,153 @@ |
||
| 45 | 45 | |
| 46 | 46 | class Coordinator { |
| 47 | 47 | |
| 48 | - /** @var IServerContainer */ |
|
| 49 | - private $serverContainer; |
|
| 50 | - |
|
| 51 | - /** @var Registry */ |
|
| 52 | - private $registry; |
|
| 53 | - |
|
| 54 | - /** @var IManager */ |
|
| 55 | - private $dashboardManager; |
|
| 56 | - |
|
| 57 | - /** @var IEventDispatcher */ |
|
| 58 | - private $eventDispatcher; |
|
| 59 | - |
|
| 60 | - /** @var LoggerInterface */ |
|
| 61 | - private $logger; |
|
| 62 | - |
|
| 63 | - /** @var RegistrationContext|null */ |
|
| 64 | - private $registrationContext; |
|
| 65 | - |
|
| 66 | - /** @var string[] */ |
|
| 67 | - private $bootedApps = []; |
|
| 68 | - |
|
| 69 | - public function __construct(IServerContainer $container, |
|
| 70 | - Registry $registry, |
|
| 71 | - IManager $dashboardManager, |
|
| 72 | - IEventDispatcher $eventListener, |
|
| 73 | - LoggerInterface $logger) { |
|
| 74 | - $this->serverContainer = $container; |
|
| 75 | - $this->registry = $registry; |
|
| 76 | - $this->dashboardManager = $dashboardManager; |
|
| 77 | - $this->eventDispatcher = $eventListener; |
|
| 78 | - $this->logger = $logger; |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - public function runInitialRegistration(): void { |
|
| 82 | - $this->registerApps(OC_App::getEnabledApps()); |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - public function runLazyRegistration(string $appId): void { |
|
| 86 | - $this->registerApps([$appId]); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * @param string[] $appIds |
|
| 91 | - */ |
|
| 92 | - private function registerApps(array $appIds): void { |
|
| 93 | - if ($this->registrationContext === null) { |
|
| 94 | - $this->registrationContext = new RegistrationContext($this->logger); |
|
| 95 | - } |
|
| 96 | - $apps = []; |
|
| 97 | - foreach ($appIds as $appId) { |
|
| 98 | - /* |
|
| 48 | + /** @var IServerContainer */ |
|
| 49 | + private $serverContainer; |
|
| 50 | + |
|
| 51 | + /** @var Registry */ |
|
| 52 | + private $registry; |
|
| 53 | + |
|
| 54 | + /** @var IManager */ |
|
| 55 | + private $dashboardManager; |
|
| 56 | + |
|
| 57 | + /** @var IEventDispatcher */ |
|
| 58 | + private $eventDispatcher; |
|
| 59 | + |
|
| 60 | + /** @var LoggerInterface */ |
|
| 61 | + private $logger; |
|
| 62 | + |
|
| 63 | + /** @var RegistrationContext|null */ |
|
| 64 | + private $registrationContext; |
|
| 65 | + |
|
| 66 | + /** @var string[] */ |
|
| 67 | + private $bootedApps = []; |
|
| 68 | + |
|
| 69 | + public function __construct(IServerContainer $container, |
|
| 70 | + Registry $registry, |
|
| 71 | + IManager $dashboardManager, |
|
| 72 | + IEventDispatcher $eventListener, |
|
| 73 | + LoggerInterface $logger) { |
|
| 74 | + $this->serverContainer = $container; |
|
| 75 | + $this->registry = $registry; |
|
| 76 | + $this->dashboardManager = $dashboardManager; |
|
| 77 | + $this->eventDispatcher = $eventListener; |
|
| 78 | + $this->logger = $logger; |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + public function runInitialRegistration(): void { |
|
| 82 | + $this->registerApps(OC_App::getEnabledApps()); |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + public function runLazyRegistration(string $appId): void { |
|
| 86 | + $this->registerApps([$appId]); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * @param string[] $appIds |
|
| 91 | + */ |
|
| 92 | + private function registerApps(array $appIds): void { |
|
| 93 | + if ($this->registrationContext === null) { |
|
| 94 | + $this->registrationContext = new RegistrationContext($this->logger); |
|
| 95 | + } |
|
| 96 | + $apps = []; |
|
| 97 | + foreach ($appIds as $appId) { |
|
| 98 | + /* |
|
| 99 | 99 | * First, we have to enable the app's autoloader |
| 100 | 100 | * |
| 101 | 101 | * @todo use $this->appManager->getAppPath($appId) here |
| 102 | 102 | */ |
| 103 | - $path = OC_App::getAppPath($appId); |
|
| 104 | - if ($path === false) { |
|
| 105 | - // Ignore |
|
| 106 | - continue; |
|
| 107 | - } |
|
| 108 | - OC_App::registerAutoloading($appId, $path); |
|
| 109 | - |
|
| 110 | - /* |
|
| 103 | + $path = OC_App::getAppPath($appId); |
|
| 104 | + if ($path === false) { |
|
| 105 | + // Ignore |
|
| 106 | + continue; |
|
| 107 | + } |
|
| 108 | + OC_App::registerAutoloading($appId, $path); |
|
| 109 | + |
|
| 110 | + /* |
|
| 111 | 111 | * Next we check if there is an application class and it implements |
| 112 | 112 | * the \OCP\AppFramework\Bootstrap\IBootstrap interface |
| 113 | 113 | */ |
| 114 | - $appNameSpace = App::buildAppNamespace($appId); |
|
| 115 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 116 | - try { |
|
| 117 | - if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { |
|
| 118 | - try { |
|
| 119 | - /** @var IBootstrap|App $application */ |
|
| 120 | - $apps[$appId] = $application = $this->serverContainer->query($applicationClassName); |
|
| 121 | - } catch (QueryException $e) { |
|
| 122 | - // Weird, but ok |
|
| 123 | - continue; |
|
| 124 | - } |
|
| 125 | - |
|
| 126 | - $application->register($this->registrationContext->for($appId)); |
|
| 127 | - } |
|
| 128 | - } catch (Throwable $e) { |
|
| 129 | - $this->logger->emergency('Error during app service registration: ' . $e->getMessage(), [ |
|
| 130 | - 'exception' => $e, |
|
| 131 | - 'app' => $appId, |
|
| 132 | - ]); |
|
| 133 | - continue; |
|
| 134 | - } |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - /** |
|
| 138 | - * Now that all register methods have been called, we can delegate the registrations |
|
| 139 | - * to the actual services |
|
| 140 | - */ |
|
| 141 | - $this->registrationContext->delegateCapabilityRegistrations($apps); |
|
| 142 | - $this->registrationContext->delegateCrashReporterRegistrations($apps, $this->registry); |
|
| 143 | - $this->registrationContext->delegateDashboardPanelRegistrations($apps, $this->dashboardManager); |
|
| 144 | - $this->registrationContext->delegateEventListenerRegistrations($this->eventDispatcher); |
|
| 145 | - $this->registrationContext->delegateContainerRegistrations($apps); |
|
| 146 | - $this->registrationContext->delegateMiddlewareRegistrations($apps); |
|
| 147 | - } |
|
| 148 | - |
|
| 149 | - public function getRegistrationContext(): ?RegistrationContext { |
|
| 150 | - return $this->registrationContext; |
|
| 151 | - } |
|
| 152 | - |
|
| 153 | - public function bootApp(string $appId): void { |
|
| 154 | - if (isset($this->bootedApps[$appId])) { |
|
| 155 | - return; |
|
| 156 | - } |
|
| 157 | - $this->bootedApps[$appId] = true; |
|
| 158 | - |
|
| 159 | - $appNameSpace = App::buildAppNamespace($appId); |
|
| 160 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 161 | - if (!class_exists($applicationClassName)) { |
|
| 162 | - // Nothing to boot |
|
| 163 | - return; |
|
| 164 | - } |
|
| 165 | - |
|
| 166 | - /* |
|
| 114 | + $appNameSpace = App::buildAppNamespace($appId); |
|
| 115 | + $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 116 | + try { |
|
| 117 | + if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { |
|
| 118 | + try { |
|
| 119 | + /** @var IBootstrap|App $application */ |
|
| 120 | + $apps[$appId] = $application = $this->serverContainer->query($applicationClassName); |
|
| 121 | + } catch (QueryException $e) { |
|
| 122 | + // Weird, but ok |
|
| 123 | + continue; |
|
| 124 | + } |
|
| 125 | + |
|
| 126 | + $application->register($this->registrationContext->for($appId)); |
|
| 127 | + } |
|
| 128 | + } catch (Throwable $e) { |
|
| 129 | + $this->logger->emergency('Error during app service registration: ' . $e->getMessage(), [ |
|
| 130 | + 'exception' => $e, |
|
| 131 | + 'app' => $appId, |
|
| 132 | + ]); |
|
| 133 | + continue; |
|
| 134 | + } |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + /** |
|
| 138 | + * Now that all register methods have been called, we can delegate the registrations |
|
| 139 | + * to the actual services |
|
| 140 | + */ |
|
| 141 | + $this->registrationContext->delegateCapabilityRegistrations($apps); |
|
| 142 | + $this->registrationContext->delegateCrashReporterRegistrations($apps, $this->registry); |
|
| 143 | + $this->registrationContext->delegateDashboardPanelRegistrations($apps, $this->dashboardManager); |
|
| 144 | + $this->registrationContext->delegateEventListenerRegistrations($this->eventDispatcher); |
|
| 145 | + $this->registrationContext->delegateContainerRegistrations($apps); |
|
| 146 | + $this->registrationContext->delegateMiddlewareRegistrations($apps); |
|
| 147 | + } |
|
| 148 | + |
|
| 149 | + public function getRegistrationContext(): ?RegistrationContext { |
|
| 150 | + return $this->registrationContext; |
|
| 151 | + } |
|
| 152 | + |
|
| 153 | + public function bootApp(string $appId): void { |
|
| 154 | + if (isset($this->bootedApps[$appId])) { |
|
| 155 | + return; |
|
| 156 | + } |
|
| 157 | + $this->bootedApps[$appId] = true; |
|
| 158 | + |
|
| 159 | + $appNameSpace = App::buildAppNamespace($appId); |
|
| 160 | + $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 161 | + if (!class_exists($applicationClassName)) { |
|
| 162 | + // Nothing to boot |
|
| 163 | + return; |
|
| 164 | + } |
|
| 165 | + |
|
| 166 | + /* |
|
| 167 | 167 | * Now it is time to fetch an instance of the App class. For classes |
| 168 | 168 | * that implement \OCP\AppFramework\Bootstrap\IBootstrap this means |
| 169 | 169 | * the instance was already created for register, but any other |
| 170 | 170 | * (legacy) code will now do their magic via the constructor. |
| 171 | 171 | */ |
| 172 | - try { |
|
| 173 | - /** @var App $application */ |
|
| 174 | - $application = $this->serverContainer->query($applicationClassName); |
|
| 175 | - if ($application instanceof IBootstrap) { |
|
| 176 | - /** @var BootContext $context */ |
|
| 177 | - $context = new BootContext($application->getContainer()); |
|
| 178 | - $application->boot($context); |
|
| 179 | - } |
|
| 180 | - } catch (QueryException $e) { |
|
| 181 | - $this->logger->error("Could not boot $appId: " . $e->getMessage(), [ |
|
| 182 | - 'exception' => $e, |
|
| 183 | - ]); |
|
| 184 | - } catch (Throwable $e) { |
|
| 185 | - $this->logger->emergency("Could not boot $appId: " . $e->getMessage(), [ |
|
| 186 | - 'exception' => $e, |
|
| 187 | - ]); |
|
| 188 | - } |
|
| 189 | - } |
|
| 190 | - |
|
| 191 | - public function isBootable(string $appId) { |
|
| 192 | - $appNameSpace = App::buildAppNamespace($appId); |
|
| 193 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 194 | - return class_exists($applicationClassName) && |
|
| 195 | - in_array(IBootstrap::class, class_implements($applicationClassName), true); |
|
| 196 | - } |
|
| 172 | + try { |
|
| 173 | + /** @var App $application */ |
|
| 174 | + $application = $this->serverContainer->query($applicationClassName); |
|
| 175 | + if ($application instanceof IBootstrap) { |
|
| 176 | + /** @var BootContext $context */ |
|
| 177 | + $context = new BootContext($application->getContainer()); |
|
| 178 | + $application->boot($context); |
|
| 179 | + } |
|
| 180 | + } catch (QueryException $e) { |
|
| 181 | + $this->logger->error("Could not boot $appId: " . $e->getMessage(), [ |
|
| 182 | + 'exception' => $e, |
|
| 183 | + ]); |
|
| 184 | + } catch (Throwable $e) { |
|
| 185 | + $this->logger->emergency("Could not boot $appId: " . $e->getMessage(), [ |
|
| 186 | + 'exception' => $e, |
|
| 187 | + ]); |
|
| 188 | + } |
|
| 189 | + } |
|
| 190 | + |
|
| 191 | + public function isBootable(string $appId) { |
|
| 192 | + $appNameSpace = App::buildAppNamespace($appId); |
|
| 193 | + $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 194 | + return class_exists($applicationClassName) && |
|
| 195 | + in_array(IBootstrap::class, class_implements($applicationClassName), true); |
|
| 196 | + } |
|
| 197 | 197 | } |
@@ -112,7 +112,7 @@ discard block |
||
| 112 | 112 | * the \OCP\AppFramework\Bootstrap\IBootstrap interface |
| 113 | 113 | */ |
| 114 | 114 | $appNameSpace = App::buildAppNamespace($appId); |
| 115 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 115 | + $applicationClassName = $appNameSpace.'\\AppInfo\\Application'; |
|
| 116 | 116 | try { |
| 117 | 117 | if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { |
| 118 | 118 | try { |
@@ -126,7 +126,7 @@ discard block |
||
| 126 | 126 | $application->register($this->registrationContext->for($appId)); |
| 127 | 127 | } |
| 128 | 128 | } catch (Throwable $e) { |
| 129 | - $this->logger->emergency('Error during app service registration: ' . $e->getMessage(), [ |
|
| 129 | + $this->logger->emergency('Error during app service registration: '.$e->getMessage(), [ |
|
| 130 | 130 | 'exception' => $e, |
| 131 | 131 | 'app' => $appId, |
| 132 | 132 | ]); |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | $this->bootedApps[$appId] = true; |
| 158 | 158 | |
| 159 | 159 | $appNameSpace = App::buildAppNamespace($appId); |
| 160 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 160 | + $applicationClassName = $appNameSpace.'\\AppInfo\\Application'; |
|
| 161 | 161 | if (!class_exists($applicationClassName)) { |
| 162 | 162 | // Nothing to boot |
| 163 | 163 | return; |
@@ -178,11 +178,11 @@ discard block |
||
| 178 | 178 | $application->boot($context); |
| 179 | 179 | } |
| 180 | 180 | } catch (QueryException $e) { |
| 181 | - $this->logger->error("Could not boot $appId: " . $e->getMessage(), [ |
|
| 181 | + $this->logger->error("Could not boot $appId: ".$e->getMessage(), [ |
|
| 182 | 182 | 'exception' => $e, |
| 183 | 183 | ]); |
| 184 | 184 | } catch (Throwable $e) { |
| 185 | - $this->logger->emergency("Could not boot $appId: " . $e->getMessage(), [ |
|
| 185 | + $this->logger->emergency("Could not boot $appId: ".$e->getMessage(), [ |
|
| 186 | 186 | 'exception' => $e, |
| 187 | 187 | ]); |
| 188 | 188 | } |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | |
| 191 | 191 | public function isBootable(string $appId) { |
| 192 | 192 | $appNameSpace = App::buildAppNamespace($appId); |
| 193 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 193 | + $applicationClassName = $appNameSpace.'\\AppInfo\\Application'; |
|
| 194 | 194 | return class_exists($applicationClassName) && |
| 195 | 195 | in_array(IBootstrap::class, class_implements($applicationClassName), true); |
| 196 | 196 | } |