container = $container; $this->class = $class; $this->logger = $logger; } public function __invoke(Event $event) { if ($this->service === null) { try { // TODO: fetch from the app containers, otherwise any custom services, // parameters and aliases won't be resolved. // See https://github.com/nextcloud/server/issues/27793 for details. $this->service = $this->container->query($this->class); } catch (QueryException $e) { $this->logger->error( sprintf( 'Could not load event listener service %s: %s. Make sure the class is auto-loadable by the Nextcloud server container', $this->class, $e->getMessage() ), [ 'exception' => $e, ] ); return; } } $this->service->handle($event); } }