/**
  * @return array|ViewModel
  */
 public function addAssociateAction()
 {
     $affiliationService = $this->getAffiliationService()->setAffiliationId($this->getEvent()->getRouteMatch()->getParam('id'));
     if ($affiliationService->isEmpty()) {
         return $this->notFoundAction();
     }
     $projectService = $this->getProjectService()->setProject($affiliationService->getAffiliation()->getProject());
     if ($projectService->isEmpty()) {
         return $this->notFoundAction();
     }
     $data = array_merge_recursive($this->getRequest()->getPost()->toArray());
     $form = new AddAssociate($affiliationService, $this->getContactService());
     $form->setData($data);
     if ($this->getRequest()->isPost() && $form->isValid()) {
         if (empty($form->getData()['cancel'])) {
             $affiliation = $affiliationService->getAffiliation();
             $affiliation->addAssociate($this->getContactService()->setContactId($form->getData()['contact'])->getContact());
             $this->getAffiliationService()->updateEntity($affiliation);
         }
         return $this->redirect()->toRoute('community/affiliation/affiliation', ['id' => $affiliationService->getAffiliation()->getId()], ['fragment' => 'contact']);
     }
     return new ViewModel(['affiliationService' => $affiliationService, 'projectService' => $projectService, 'form' => $form]);
 }
 /**
  * @return array|ViewModel
  */
 public function addAssociateAction()
 {
     $affiliationService = $this->getAffiliationService()->setAffiliationId($this->getEvent()->getRouteMatch()->getParam('id'));
     if ($affiliationService->isEmpty()) {
         return $this->notFoundAction();
     }
     $projectService = $this->getProjectService()->setProject($affiliationService->getAffiliation()->getProject());
     if ($projectService->isEmpty()) {
         return $this->notFoundAction();
     }
     $data = array_merge_recursive($this->getRequest()->getPost()->toArray());
     $form = new AddAssociate($affiliationService, $this->getContactService());
     $form->setData($data);
     if ($this->getRequest()->isPost() && $form->isValid()) {
         if (empty($form->getData()['cancel'])) {
             $affiliation = $affiliationService->getAffiliation();
             $affiliation->addAssociate($this->getContactService()->setContactId($form->getData()['contact'])->getContact());
             $this->getAffiliationService()->updateEntity($affiliation);
         }
         $this->flashMessenger()->setNamespace('success')->addMessage(sprintf($this->translate("txt-affiliation-%s-has-successfully-been-updated"), $affiliationService->getAffiliation()));
         return $this->redirect()->toRoute('community/affiliation/affiliation', ['id' => $affiliationService->getAffiliation()->getId()], ['fragment' => 'contact']);
     }
     return new ViewModel(['affiliationService' => $affiliationService, 'projectService' => $projectService, 'form' => $form]);
 }