/** * Deletes the specified user and all remaining content in his personal workspaces * * @param User $user The user to delete * @return void * @throws Exception * @api */ public function deleteUser(User $user) { $backendUserRole = $this->policyService->getRole('Neos.Neos:AbstractEditor'); foreach ($user->getAccounts() as $account) { /** @var Account $account */ if ($account->hasRole($backendUserRole)) { $this->deletePersonalWorkspace($account->getAccountIdentifier()); } $this->accountRepository->remove($account); } $this->removeOwnerFromUsersWorkspaces($user); $this->partyRepository->remove($user); $this->emitUserDeleted($user); }