diff --git a/apps/user_status/appinfo/app.php b/apps/user_status/appinfo/app.php deleted file mode 100644 index a4764f00f1e09..0000000000000 --- a/apps/user_status/appinfo/app.php +++ /dev/null @@ -1,32 +0,0 @@ - - * - * @license AGPL-3.0 - * - * This code is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero General Public License, version 3, - * as published by the Free Software Foundation. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License, version 3, - * along with this program. If not, see - * - */ - -use OCA\UserStatus\AppInfo\Application; - -/** @var Application $app */ -$app = \OC::$server->query(Application::class); -$app->registerCapabilities(); -$app->registerEvents(); -$app->registerInitialState(); diff --git a/apps/user_status/lib/AppInfo/Application.php b/apps/user_status/lib/AppInfo/Application.php index 99402aeb16777..85b6929a9ed72 100644 --- a/apps/user_status/lib/AppInfo/Application.php +++ b/apps/user_status/lib/AppInfo/Application.php @@ -30,6 +30,9 @@ use OCA\UserStatus\Listener\UserLiveStatusListener; use OCA\UserStatus\Service\JSDataService; use OCP\AppFramework\App; +use OCP\AppFramework\Bootstrap\IBootContext; +use OCP\AppFramework\Bootstrap\IBootstrap; +use OCP\AppFramework\Bootstrap\IRegistrationContext; use OCP\AppFramework\Http\TemplateResponse; use OCP\EventDispatcher\IEventDispatcher; use OCP\IInitialStateService; @@ -41,7 +44,7 @@ * * @package OCA\UserStatus\AppInfo */ -class Application extends App { +class Application extends App implements IBootstrap { /** @var string */ public const APP_ID = 'user_status'; @@ -56,43 +59,35 @@ public function __construct(array $urlParams = []) { } /** - * Registers capabilities that will be exposed - * via the OCS API endpoint + * @inheritDoc */ - public function registerCapabilities(): void { - $this->getContainer() - ->registerCapability(Capabilities::class); + public function register(IRegistrationContext $context): void { + // Register OCS Capabilities + $context->registerCapability(Capabilities::class); + + // Register Event Listeners + $context->registerEventListener(UserDeletedEvent::class, UserDeletedListener::class); + $context->registerEventListener(UserLiveStatusEvent::class, UserLiveStatusListener::class); } /** - * Registers a listener for the user-delete event - * to automatically delete a user's status on - * account deletion + * @inheritDoc */ - public function registerEvents(): void { - /** @var IEventDispatcher $dispatcher */ - $dispatcher = $this->getContainer() - ->query(IEventDispatcher::class); + public function boot(IBootContext $context): void { + $appContainer = $context->getAppContainer(); - $dispatcher->addServiceListener(UserDeletedEvent::class, UserDeletedListener::class); - $dispatcher->addServiceListener(UserLiveStatusEvent::class, UserLiveStatusListener::class); + /** @var IInitialStateService $initialState */ + $initialState = $appContainer->query(IInitialStateService::class); + $initialState->provideLazyInitialState(self::APP_ID, 'status', static function () use ($appContainer) { + /** @var JSDataService $data */ + $data = $appContainer->query(JSDataService::class); + return $data; + }); + $dispatcher = $appContainer->query(IEventDispatcher::class); $dispatcher->addListener(TemplateResponse::EVENT_LOAD_ADDITIONAL_SCRIPTS_LOGGEDIN, static function () { \OC_Util::addScript('user_status', 'user-status-menu'); \OC_Util::addStyle('user_status', 'user-status-menu'); }); } - - public function registerInitialState(): void { - $container = $this->getContainer(); - - /** @var IInitialStateService $initialState */ - $initialState = $container->query(IInitialStateService::class); - - $initialState->provideLazyInitialState(self::APP_ID, 'status', static function () use ($container) { - /** @var JSDataService $data */ - $data = $container->query(JSDataService::class); - return $data; - }); - } }