protected function removeOwnerFromUsersWorkspaces(User $user) { /** @var Workspace $workspace */ foreach ($this->workspaceRepository->findByOwner($user) as $workspace) { $workspace->setOwner(null); $this->workspaceRepository->update($workspace); } }