/**
  * Deletes a key-value combination from the database.
  * 
  * (non-PHPdoc)
  * @see PartKeepr\Service.RestfulService::destroy()
  */
 public function destroy()
 {
     if ($this->hasParameter("user_id") && SessionManager::getCurrentSession()->getUser()->isAdmin()) {
         UserPreference::deletePreference(User::loadById($this->getParameter("user_id")), $this->getParameter("key"));
     } else {
         UserPreference::deletePreference($this->getUser(), $this->getParameter("key"));
     }
 }
Ejemplo n.º 2
0
 /**
  * Makes sure that an exception is thrown when attempting to delete a preference if the user is not persistant yet.
  *
  * @expectedException PartKeepr\Util\Exceptions\EntityNotPersistantException
  */
 public function testDeleteNonPersistantUserPreference()
 {
     $user = new User();
     UserPreference::deletePreference($user, "test");
 }
Ejemplo n.º 3
0
 /**
  * Deletes the given preference
  *
  * @param string $preferenceKey The preference key
  * @return UserPreference The user preference object
  * @throws UserPreferenceNotFoundException If the preference key was not found
  * @throws EntityNotPersistantException		Thrown if the entity is not persistant
  */
 public function deletePreference($preferenceKey)
 {
     UserPreference::deletePreference($this, $preferenceKey);
 }