clearCb( function (string $uid) use ($dispatcher): void { $dispatcher->dispatchTyped(new BeforeUserIdUnassignedEvent($uid)); /** @psalm-suppress UndefinedInterfaceMethod For now we have to emit, will be removed when all hooks are removed */ Server::get(IUserManager::class)->emit('\OC\User', 'preUnassignedUserId', [$uid]); }, function (string $uid) use ($dispatcher): void { $dispatcher->dispatchTyped(new UserIdUnassignedEvent($uid)); /** @psalm-suppress UndefinedInterfaceMethod For now we have to emit, will be removed when all hooks are removed */ Server::get(IUserManager::class)->emit('\OC\User', 'postUnassignedUserId', [$uid]); } ); } elseif ($subject === 'group') { $mapping = new GroupMapping(Server::get(IDBConnection::class)); $result = $mapping->clear(); } if ($mapping === null || !$result) { $l = Util::getL10N('user_ldap'); throw new \Exception($l->t('Failed to clear the mappings.')); } \OC_JSON::success(); } catch (\Exception $e) { \OC_JSON::error(['message' => $e->getMessage()]); }