/** * Attempts to delete the Capsule specified by the ID * * @param mixed $id The ID of the Capsule to delete */ public function deleteCapsule($id) { // Make sure the ID exists if (!$id) { throw new BadRequestException(); } // Set the ID $this->Capsule->id = $id; // Make sure the Capsule exists and that it belongs to the authenticated User if (!$this->Capsule->exists() || !$this->Capsule->ownedBy($this->Auth->user('id'))) { throw new NotFoundException(); } // Attempt to delete the Capsule if ($this->Capsule->softDelete($id)) { // Indicate a no content response $this->sendNoContentResponse(); return; } else { throw new InternalErrorException(); } }