public function unsetUser() { $this->__load(); return parent::unsetUser(); }
/** * Do the heavy lifting for deleting a user * * @param \Entities\Contact $contact The contact entity */ private function _deleteUser($contact) { $user = $contact->getUser(); // delete all the user's preferences foreach ($user->getPreferences() as $pref) { $user->removePreference($pref); $this->getD2EM()->remove($pref); } // delete all the user's login records foreach ($user->getLastLogins() as $ll) { $user->removeLastLogin($ll); $this->getD2EM()->remove($ll); } // delete all the user's API keys foreach ($user->getApiKeys() as $ak) { $user->removeApiKey($ak); $this->getD2EM()->remove($ak); } // clear the user from the contact and remove the user then $contact->unsetUser(); $this->getD2EM()->remove($user); // in case the user is currently logged in: $this->clearUserFromCache($user->getId()); $this->getLogger()->info("{$this->getUser()->getUsername()} deleted user {$user->getUsername()}"); }