/** * Saves the current object to the database. * * The object saving is done in a transaction and handled by the doSave() method. * * @param mixed $con An optional connection object * * @return mixed The current saved object * * @see doSave() * * @throws sfValidatorError If the form is not valid */ public function save($con = null) { if (!$this->isValid()) { throw $this->getErrorSchema(); } if (null === $con) { $con = $this->getConnection(); } $request = sfContext::getInstance()->getRequest(); $response = sfContext::getInstance()->getResponse(); $actual_cookie = aPollToolkit::getCookieContent($request); $poll = Doctrine_Core::getTable('aPollPoll')->findOneById($this->getValue('poll_id')); aPollToolkit::setShowPollToCookie($request, $response, $poll, aPollToolkit::getPollAllowMultipleSubmissions($poll)); try { $answer = $this->doSave($con); } catch (Exception $exc) { $response->setCookie($actual_cookie); throw $exc; } return $answer; }