/** * @return ViewModel */ public function uploadAction() { $call = $this->getCallService()->findLastCall(); if (!is_null($callId = $this->params('callId'))) { $call = $this->getCallService()->setCallId($callId)->getCall(); if ($this->getCallService()->isEmpty()) { return $this->notFoundAction(); } $nda = $this->getCallService()->findNdaByCallAndContact($call, $this->zfcUserAuthentication()->getIdentity()); } elseif (!is_null($call)) { $nda = $this->getCallService()->findNdaByCallAndContact($call, $this->zfcUserAuthentication()->getIdentity()); } else { $nda = $this->getCallService()->findNdaByContact($this->zfcUserAuthentication()->getIdentity()); } $data = array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray()); $form = new UploadNda(); $form->setData($data); if ($this->getRequest()->isPost() && $form->isValid()) { $fileData = $form->getData('file'); $this->getCallService()->uploadNda($fileData['file'], $this->zfcUserAuthentication()->getIdentity(), $call); $this->flashMessenger()->setNamespace('success')->addMessage(sprintf($this->translate("txt-nda-has-been-uploaded-successfully"))); return $this->redirect()->toRoute('community'); } return new ViewModel(['call' => $call, 'nda' => $nda, 'form' => $form]); }
/** * @return ViewModel */ public function uploadAction() { $call = null; if (!is_null($callId = $this->getEvent()->getRouteMatch()->getParam('id'))) { $call = $this->getCallService()->setCallId($callId)->getCall(); if ($this->getCallService()->isEmpty()) { return $this->notFoundAction(); } $nda = $this->getCallService()->findNdaByCallAndContact($call, $this->zfcUserAuthentication()->getIdentity()); } else { $nda = $this->getCallService()->findNdaByContact($this->zfcUserAuthentication()->getIdentity()); } $data = array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray()); $form = new UploadNda(); $form->setData($data); if ($this->getRequest()->isPost() && $form->isValid()) { $fileData = $form->getData('file'); $nda = $this->getCallService()->uploadNda($fileData['file'], $this->zfcUserAuthentication()->getIdentity(), $call); return $this->redirect()->toRoute('program/nda/view', ['id' => $nda->getId()]); } return new ViewModel(['call' => $call, 'nda' => $nda, 'form' => $form]); }