コード例 #1
0
ファイル: SurveyPage.php プロジェクト: Thingee/openstack-org
 /**
  * @return ISurvey|null
  * @throws NotFoundEntityException
  */
 private function getCurrentSurveyInstance()
 {
     // get current template
     $current_template = $this->SurveyTemplate();
     if (is_null($current_template)) {
         throw new NotFoundEntityException('SurveyTemplate', 'current template not set');
     }
     if ($current_template->isVoid()) {
         throw new NotFoundEntityException('SurveyTemplate', 'current template is void!');
     }
     if (!is_null($this->current_survey)) {
         return $this->current_survey;
     }
     $this->current_survey = $this->survey_repository->getByTemplateAndCreator($current_template->getIdentifier(), Member::currentUserID());
     // if not, create the survey and do the population
     if (is_null($this->current_survey)) {
         $this->current_survey = $this->survey_manager->buildSurvey($current_template->getIdentifier(), Member::currentUserID());
         // check if we should pre populate with former data ....
         if ($current_template->shouldPrepopulateWithFormerData()) {
             $this->survey_manager->doAutopopulation($this->current_survey, SurveyDataAutoPopulationStrategyFactory::build(SurveyDataAutoPopulationStrategyFactory::NEW_STRATEGY));
         }
     }
     $this->current_survey = $this->survey_manager->updateSurveyWithTemplate($this->current_survey, $current_template);
     return $this->current_survey;
 }