/** * Attempts to save the Capsule and Memoir data in the HTTP request. If successful, the capsule data will * be returned. * * @param CakeRequest $request The current HTTP request */ public function createCapsule(CakeRequest $request) { // Parse the Capsule data $data = $this->parseCapsuleData($request->data); // Parse the Memoir data $data = $this->parseMemoirData($request->data, $data); // Save if ($this->Capsule->saveAllWithUploads($data, array('deep' => true, 'fieldList' => $this->Capsule->fieldListCreate, 'associateOwner' => true, 'updateCtagForUser' => $this->Auth->user('id')))) { // Get the ID of the new Capsule $capsuleId = $this->Capsule->getLastInsertID(); // Get the Capsule $capsule = $this->Capsule->getByIdForUser($capsuleId, $this->Auth->user('id')); $this->controller->set('capsule', $capsule); return; } else { // See if there were validation errors or if an internal error occurred $this->handleSaveError($this->Capsule); return; } }