/** * @return void */ public function createAction() { session_start(); $answers = $this->request->getArguments('obj'); for ($i = 0; $i < count($answers['obj']); $i++) { $question = $this->questionRepository->findByIdentifier($answers['obj']['question-' . ($i + 1)]['__identity']); $user = $_SESSION['identity']; $answer = new \SKL\Test\Domain\Model\Answer(); $answer->setQuestion($question); $user = $this->entityManager->merge($user); $answer->setUser($user); $this->entityManager->flush(); $answer->setName($answers['obj']['question-' . ($i + 1)][0]); $this->answerRepository->add($answer); } $this->redirect('index', 'form'); }
/** * {@inheritDoc} */ public function setUser(\SKL\Test\Domain\Model\User $user) { $this->__initializer__ && $this->__initializer__->__invoke($this, 'setUser', array($user)); return parent::setUser($user); }