Exemplo n.º 1
0
 /**
  * @param ISurveyTemplate $template
  * @param  $owner
  * @return ISurvey
  */
 public function build(ISurveyTemplate $template, $owner)
 {
     $survey = new Survey();
     $survey->TemplateID = $template->getIdentifier();
     $survey->CreatedByID = $owner->getIdentifier();
     $i = 0;
     foreach ($template->getSteps() as $step_template) {
         ++$i;
         $new_step = null;
         if ($step_template instanceof SurveyDynamicEntityStepTemplate) {
             $new_step = new SurveyDynamicEntityStep();
         } else {
             if ($step_template instanceof SurveyRegularStepTemplate) {
                 $new_step = new SurveyRegularStep();
             } else {
                 $new_step = new SurveyStep();
             }
         }
         $new_step->TemplateID = $step_template->getIdentifier();
         $survey->addStep($new_step);
         if ($i == 1) {
             $survey->registerCurrentStep($new_step);
             $survey->registerAllowedMaxStep($new_step);
         }
     }
     return $survey;
 }