@@ -39,106 +39,106 @@ |
||
| 39 | 39 | |
| 40 | 40 | class Coordinator { |
| 41 | 41 | |
| 42 | - /** @var IServerContainer */ |
|
| 43 | - private $serverContainer; |
|
| 42 | + /** @var IServerContainer */ |
|
| 43 | + private $serverContainer; |
|
| 44 | 44 | |
| 45 | - /** @var IEventDispatcher */ |
|
| 46 | - private $eventDispatcher; |
|
| 45 | + /** @var IEventDispatcher */ |
|
| 46 | + private $eventDispatcher; |
|
| 47 | 47 | |
| 48 | - /** @var ILogger */ |
|
| 49 | - private $logger; |
|
| 48 | + /** @var ILogger */ |
|
| 49 | + private $logger; |
|
| 50 | 50 | |
| 51 | - public function __construct(IServerContainer $container, |
|
| 52 | - IEventDispatcher $eventListener, |
|
| 53 | - ILogger $logger) { |
|
| 54 | - $this->serverContainer = $container; |
|
| 55 | - $this->eventDispatcher = $eventListener; |
|
| 56 | - $this->logger = $logger; |
|
| 57 | - } |
|
| 51 | + public function __construct(IServerContainer $container, |
|
| 52 | + IEventDispatcher $eventListener, |
|
| 53 | + ILogger $logger) { |
|
| 54 | + $this->serverContainer = $container; |
|
| 55 | + $this->eventDispatcher = $eventListener; |
|
| 56 | + $this->logger = $logger; |
|
| 57 | + } |
|
| 58 | 58 | |
| 59 | - public function runRegistration(): void { |
|
| 60 | - $context = new RegistrationContext($this->logger); |
|
| 61 | - $apps = []; |
|
| 62 | - foreach (OC_App::getEnabledApps() as $appId) { |
|
| 63 | - /* |
|
| 59 | + public function runRegistration(): void { |
|
| 60 | + $context = new RegistrationContext($this->logger); |
|
| 61 | + $apps = []; |
|
| 62 | + foreach (OC_App::getEnabledApps() as $appId) { |
|
| 63 | + /* |
|
| 64 | 64 | * First, we have to enable the app's autoloader |
| 65 | 65 | * |
| 66 | 66 | * @todo use $this->appManager->getAppPath($appId) here |
| 67 | 67 | */ |
| 68 | - $path = OC_App::getAppPath($appId); |
|
| 69 | - if ($path === false) { |
|
| 70 | - // Ignore |
|
| 71 | - continue; |
|
| 72 | - } |
|
| 73 | - OC_App::registerAutoloading($appId, $path); |
|
| 68 | + $path = OC_App::getAppPath($appId); |
|
| 69 | + if ($path === false) { |
|
| 70 | + // Ignore |
|
| 71 | + continue; |
|
| 72 | + } |
|
| 73 | + OC_App::registerAutoloading($appId, $path); |
|
| 74 | 74 | |
| 75 | - /* |
|
| 75 | + /* |
|
| 76 | 76 | * Next we check if there is an application class and it implements |
| 77 | 77 | * the \OCP\AppFramework\Bootstrap\IBootstrap interface |
| 78 | 78 | */ |
| 79 | - $appNameSpace = App::buildAppNamespace($appId); |
|
| 80 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 81 | - if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { |
|
| 82 | - try { |
|
| 83 | - /** @var IBootstrap|App $application */ |
|
| 84 | - $apps[$appId] = $application = $this->serverContainer->query($applicationClassName); |
|
| 85 | - } catch (QueryException $e) { |
|
| 86 | - // Weird, but ok |
|
| 87 | - return; |
|
| 88 | - } |
|
| 89 | - try { |
|
| 90 | - $application->register($context->for($appId)); |
|
| 91 | - } catch (Throwable $e) { |
|
| 92 | - $this->logger->logException($e, [ |
|
| 93 | - 'message' => 'Error during app service registration: ' . $e->getMessage(), |
|
| 94 | - 'level' => ILogger::FATAL, |
|
| 95 | - ]); |
|
| 96 | - } |
|
| 97 | - } |
|
| 98 | - } |
|
| 79 | + $appNameSpace = App::buildAppNamespace($appId); |
|
| 80 | + $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 81 | + if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { |
|
| 82 | + try { |
|
| 83 | + /** @var IBootstrap|App $application */ |
|
| 84 | + $apps[$appId] = $application = $this->serverContainer->query($applicationClassName); |
|
| 85 | + } catch (QueryException $e) { |
|
| 86 | + // Weird, but ok |
|
| 87 | + return; |
|
| 88 | + } |
|
| 89 | + try { |
|
| 90 | + $application->register($context->for($appId)); |
|
| 91 | + } catch (Throwable $e) { |
|
| 92 | + $this->logger->logException($e, [ |
|
| 93 | + 'message' => 'Error during app service registration: ' . $e->getMessage(), |
|
| 94 | + 'level' => ILogger::FATAL, |
|
| 95 | + ]); |
|
| 96 | + } |
|
| 97 | + } |
|
| 98 | + } |
|
| 99 | 99 | |
| 100 | - /** |
|
| 101 | - * Now that all register methods have been called, we can delegate the registrations |
|
| 102 | - * to the actual services |
|
| 103 | - */ |
|
| 104 | - $context->delegateCapabilityRegistrations($apps); |
|
| 105 | - $context->delegateEventListenerRegistrations($this->eventDispatcher); |
|
| 106 | - $context->delegateContainerRegistrations($apps); |
|
| 107 | - $context->delegateMiddlewareRegistrations($apps); |
|
| 108 | - } |
|
| 100 | + /** |
|
| 101 | + * Now that all register methods have been called, we can delegate the registrations |
|
| 102 | + * to the actual services |
|
| 103 | + */ |
|
| 104 | + $context->delegateCapabilityRegistrations($apps); |
|
| 105 | + $context->delegateEventListenerRegistrations($this->eventDispatcher); |
|
| 106 | + $context->delegateContainerRegistrations($apps); |
|
| 107 | + $context->delegateMiddlewareRegistrations($apps); |
|
| 108 | + } |
|
| 109 | 109 | |
| 110 | - public function bootApp(string $appId): void { |
|
| 111 | - $appNameSpace = App::buildAppNamespace($appId); |
|
| 112 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 113 | - if (!class_exists($applicationClassName)) { |
|
| 114 | - // Nothing to boot |
|
| 115 | - return; |
|
| 116 | - } |
|
| 110 | + public function bootApp(string $appId): void { |
|
| 111 | + $appNameSpace = App::buildAppNamespace($appId); |
|
| 112 | + $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 113 | + if (!class_exists($applicationClassName)) { |
|
| 114 | + // Nothing to boot |
|
| 115 | + return; |
|
| 116 | + } |
|
| 117 | 117 | |
| 118 | - /* |
|
| 118 | + /* |
|
| 119 | 119 | * Now it is time to fetch an instance of the App class. For classes |
| 120 | 120 | * that implement \OCP\AppFramework\Bootstrap\IBootstrap this means |
| 121 | 121 | * the instance was already created for register, but any other |
| 122 | 122 | * (legacy) code will now do their magic via the constructor. |
| 123 | 123 | */ |
| 124 | - try { |
|
| 125 | - /** @var App $application */ |
|
| 126 | - $application = $this->serverContainer->query($applicationClassName); |
|
| 127 | - if ($application instanceof IBootstrap) { |
|
| 128 | - /** @var BootContext $context */ |
|
| 129 | - $context = new BootContext($application->getContainer()); |
|
| 130 | - $application->boot($context); |
|
| 131 | - } |
|
| 132 | - } catch (QueryException $e) { |
|
| 133 | - $this->logger->logException($e, [ |
|
| 134 | - 'message' => "Could not boot $appId" . $e->getMessage(), |
|
| 135 | - ]); |
|
| 136 | - return; |
|
| 137 | - } catch (Throwable $e) { |
|
| 138 | - $this->logger->logException($e, [ |
|
| 139 | - 'message' => "Could not boot $appId" . $e->getMessage(), |
|
| 140 | - 'level' => ILogger::FATAL, |
|
| 141 | - ]); |
|
| 142 | - } |
|
| 143 | - } |
|
| 124 | + try { |
|
| 125 | + /** @var App $application */ |
|
| 126 | + $application = $this->serverContainer->query($applicationClassName); |
|
| 127 | + if ($application instanceof IBootstrap) { |
|
| 128 | + /** @var BootContext $context */ |
|
| 129 | + $context = new BootContext($application->getContainer()); |
|
| 130 | + $application->boot($context); |
|
| 131 | + } |
|
| 132 | + } catch (QueryException $e) { |
|
| 133 | + $this->logger->logException($e, [ |
|
| 134 | + 'message' => "Could not boot $appId" . $e->getMessage(), |
|
| 135 | + ]); |
|
| 136 | + return; |
|
| 137 | + } catch (Throwable $e) { |
|
| 138 | + $this->logger->logException($e, [ |
|
| 139 | + 'message' => "Could not boot $appId" . $e->getMessage(), |
|
| 140 | + 'level' => ILogger::FATAL, |
|
| 141 | + ]); |
|
| 142 | + } |
|
| 143 | + } |
|
| 144 | 144 | } |
@@ -77,7 +77,7 @@ discard block |
||
| 77 | 77 | * the \OCP\AppFramework\Bootstrap\IBootstrap interface |
| 78 | 78 | */ |
| 79 | 79 | $appNameSpace = App::buildAppNamespace($appId); |
| 80 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 80 | + $applicationClassName = $appNameSpace.'\\AppInfo\\Application'; |
|
| 81 | 81 | if (class_exists($applicationClassName) && in_array(IBootstrap::class, class_implements($applicationClassName), true)) { |
| 82 | 82 | try { |
| 83 | 83 | /** @var IBootstrap|App $application */ |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | $application->register($context->for($appId)); |
| 91 | 91 | } catch (Throwable $e) { |
| 92 | 92 | $this->logger->logException($e, [ |
| 93 | - 'message' => 'Error during app service registration: ' . $e->getMessage(), |
|
| 93 | + 'message' => 'Error during app service registration: '.$e->getMessage(), |
|
| 94 | 94 | 'level' => ILogger::FATAL, |
| 95 | 95 | ]); |
| 96 | 96 | } |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | |
| 110 | 110 | public function bootApp(string $appId): void { |
| 111 | 111 | $appNameSpace = App::buildAppNamespace($appId); |
| 112 | - $applicationClassName = $appNameSpace . '\\AppInfo\\Application'; |
|
| 112 | + $applicationClassName = $appNameSpace.'\\AppInfo\\Application'; |
|
| 113 | 113 | if (!class_exists($applicationClassName)) { |
| 114 | 114 | // Nothing to boot |
| 115 | 115 | return; |
@@ -131,12 +131,12 @@ discard block |
||
| 131 | 131 | } |
| 132 | 132 | } catch (QueryException $e) { |
| 133 | 133 | $this->logger->logException($e, [ |
| 134 | - 'message' => "Could not boot $appId" . $e->getMessage(), |
|
| 134 | + 'message' => "Could not boot $appId".$e->getMessage(), |
|
| 135 | 135 | ]); |
| 136 | 136 | return; |
| 137 | 137 | } catch (Throwable $e) { |
| 138 | 138 | $this->logger->logException($e, [ |
| 139 | - 'message' => "Could not boot $appId" . $e->getMessage(), |
|
| 139 | + 'message' => "Could not boot $appId".$e->getMessage(), |
|
| 140 | 140 | 'level' => ILogger::FATAL, |
| 141 | 141 | ]); |
| 142 | 142 | } |