2525use OCP \AppFramework \Bootstrap \IBootstrap ;
2626use OCP \AppFramework \Bootstrap \IRegistrationContext ;
2727use OCP \AppFramework \Http \Events \BeforeTemplateRenderedEvent ;
28- use OCP \AppFramework \IAppContainer ;
2928use OCP \EventDispatcher \IEventDispatcher ;
3029use OCP \IGroupManager ;
31- use OCP \IServerContainer ;
3230use OCP \IUserManager ;
31+ use OCP \IUserSession ;
3332use OCP \Notification \IManager as INotificationManager ;
3433use OCP \Share \Events \ShareCreatedEvent ;
3534use OCP \User \Events \UserChangedEvent ;
3635use OCP \User \Events \UserFirstTimeLoggedInEvent ;
36+ use Psr \Container \ContainerInterface ;
3737
3838class Application extends App implements IBootstrap {
3939 public const APP_ID = 'guests ' ;
@@ -55,26 +55,27 @@ public function register(IRegistrationContext $context): void {
5555 public function boot (IBootContext $ context ): void {
5656 // need to cheat here since there's no way to register these in IRegistrationContext
5757 $ container = $ context ->getServerContainer ();
58- $ container ->get (IUserManager::class)->registerBackend ($ container ->query (UserBackend::class));
59- $ container ->get (IGroupManager::class)->addBackend ($ container ->query (GroupBackend::class));
58+ $ container ->get (IUserManager::class)->registerBackend ($ container ->get (UserBackend::class));
59+ $ container ->get (IGroupManager::class)->addBackend ($ container ->get (GroupBackend::class));
6060
6161 $ this ->setupGuestManagement ($ context ->getAppContainer (), $ context ->getServerContainer ());
6262 $ this ->setupGuestRestrictions ($ context ->getAppContainer (), $ context ->getServerContainer ());
6363 $ this ->setupNotifications ($ context ->getAppContainer ());
64- $ context ->getAppContainer ()->query (RestrictionManager::class)->lateSetupRestrictions ();
64+ $ context ->getAppContainer ()->get (RestrictionManager::class)->lateSetupRestrictions ();
6565 }
6666
67- private function setupGuestManagement (IAppContainer $ container , IServerContainer $ server ): void {
68- $ hookManager = $ container ->query (Hooks::class);
67+ private function setupGuestManagement (ContainerInterface $ container , ContainerInterface $ server ): void {
68+ $ hookManager = $ container ->get (Hooks::class);
6969 $ server ->get (IEventDispatcher::class)->addListener (ShareCreatedEvent::class, [$ hookManager , 'handlePostShare ' ]);
7070 $ server ->get (IEventDispatcher::class)->addListener (UserFirstTimeLoggedInEvent::class, [$ hookManager , 'handleFirstLogin ' ]);
7171 }
7272
73- private function setupGuestRestrictions (IAppContainer $ container , IServerContainer $ server ): void {
74- $ userSession = $ server ->getUserSession ();
73+ private function setupGuestRestrictions (ContainerInterface $ container , ContainerInterface $ server ): void {
74+ /** @var IUserSession $userSession */
75+ $ userSession = $ server ->get (IUserSession::class);
7576 $ user = $ userSession ->getUser ();
7677 /** @var RestrictionManager $restrictionManager */
77- $ restrictionManager = $ container ->query (RestrictionManager::class);
78+ $ restrictionManager = $ container ->get (RestrictionManager::class);
7879
7980 if ($ user ) {
8081 $ restrictionManager ->verifyAccess ();
@@ -87,8 +88,8 @@ private function setupGuestRestrictions(IAppContainer $container, IServerContain
8788 }
8889 }
8990
90- private function setupNotifications (IAppContainer $ container ): void {
91- $ notificationManager = $ container ->query (INotificationManager::class);
91+ private function setupNotifications (ContainerInterface $ container ): void {
92+ $ notificationManager = $ container ->get (INotificationManager::class);
9293 $ notificationManager ->registerNotifierService (Notifier::class);
9394 }
9495}
0 commit comments