/**
  * @param ISummit $summit
  * @param Member $creator
  * @param array $data
  * @return IPresentation
  */
 public function registerPresentationOn(ISummit $summit, Member $creator, array $data)
 {
     return $this->tx_manager->transaction(function () use($summit, $creator, $data) {
         $speaker = $creator->getSpeakerProfile();
         $presentation = Presentation::create();
         $presentation->Title = trim($data['Title']);
         $presentation->TypeID = intval($data['TypeID']);
         $presentation->Level = trim($data['Level']);
         $presentation->ShortDescription = trim($data['ShortDescription']);
         $presentation->ProblemAddressed = trim($data['ProblemAddressed']);
         $presentation->AttendeesExpectedLearnt = trim($data['AttendeesExpectedLearnt']);
         $presentation->CategoryID = intval(trim($data['CategoryID']));
         if (intval($presentation->CategoryID) > 0) {
             $category = PresentationCategory::get()->byID($presentation->CategoryID);
             if (is_null($category)) {
                 throw new NotFoundEntityException('category not found!.');
             }
             $limit = $this->getSubmissionLimitFor($speaker, $category);
             $count = $summit->isPublicCategory($category) ? intval($speaker->getPublicCategoryPresentationsBySummit($summit)->count()) + intval($speaker->getPublicCategoryOwnedPresentationsBySummit($summit)->count()) : intval($speaker->getPrivateCategoryPresentationsBySummit($summit, $summit->getPrivateGroupFor($category))->count()) + intval($speaker->getPrivateCategoryOwnedPresentationsBySummit($summit, $summit->getPrivateGroupFor($category))->count());
             if ($count >= $limit) {
                 throw new EntityValidationException(sprintf('*You reached the limit (%s) of presentations.', $limit));
             }
         }
         if (isset($data['OtherTopic'])) {
             $presentation->OtherTopic = trim($data['OtherTopic']);
         }
         $presentation->SummitID = $summit->getIdentifier();
         $presentation->CreatorID = $creator->ID;
         $presentation->Progress = Presentation::PHASE_SUMMARY;
         $presentation->write();
         if (isset($data["PresentationLink"])) {
             foreach ($data["PresentationLink"] as $id => $val) {
                 if (empty($val)) {
                     continue;
                 }
                 $presentation->Materials()->add(PresentationLink::create(array('Name' => trim($val), 'Link' => trim($val))));
             }
         }
         $extra_questions = $presentation->Category()->Exists() ? $presentation->Category()->ExtraQuestions() : array();
         foreach ($extra_questions as $question) {
             if (!isset($data[$question->Name])) {
                 continue;
             }
             $answer_value = $data[$question->Name];
             if (empty($answer_value)) {
                 continue;
             }
             if (!($answer = $presentation->findAnswerByQuestion($question))) {
                 $answer = new TrackAnswer();
             }
             if (is_array($answer_value)) {
                 $answer_value = str_replace('{comma}', ',', $answer_value);
                 $answer->Value = implode(',', $answer_value);
             } else {
                 $answer->Value = $answer_value;
             }
             $answer->QuestionID = $question->getIdentifier();
             $answer->write();
             $presentation->ExtraAnswers()->add($answer);
         }
         return $presentation;
     });
 }