/** * Returns anketa result by anketa and respondent * * @param RM_Anketa_Entity_Object obAnketa * @param RM_Anketa_iRespondent obRespondent * @return RM_Anketa_Result_Object **/ public function getResult(RM_Anketa_Entity_Object $obAnketa, RM_Anketa_iRespondent $obRespondent) { return $this->_mapper->storage('result')->loadObjectByKey('anketa_respondent', array($obAnketa->id(), $obRespondent->getRespondentId())); }
/** * Creates (not save) anketa result object * * @param RM_Anketa_Entity_Object obAnketa * @param RM_Anketa_iRespondent obRespondent * @return RM_Anketa_Result_Object **/ public function createResult(RM_Anketa_Entity_Object $obAnketa, RM_Anketa_iRespondent $obRespondent) { if ($obAnketa->respondent_type !== $obRespondent->getRespondentType()) { throw new RM_Base_Exception_BadUsage(__METHOD__ . "(): inappropriate respondent type. `" . $obAnketa->respondent_type . "` expected, `" . $obRespondent->getRespondentType() . "` given."); } $data = array(); $data['anketa_id'] = $obAnketa->id(); $data['respondent_id'] = $obRespondent->getRespondentId(); $data['respondent_type'] = $obRespondent->getRespondentType(); if (!isset($data['begin_time'])) { $data['begin_time'] = M('Date')->dbDateTime(); } return $this->_storages['result']->createObject($data); }