Example #1
0
 public function testFormHasCorrectInputFilter()
 {
     $uploadDoaForm = new Comment();
     $inputFilter = $uploadDoaForm->getInputFilterSpecification();
     $this->assertTrue(is_array($inputFilter));
     $this->assertArrayHasKey('comment', $inputFilter);
 }
Example #2
0
 /**
  * @return string
  */
 public function parseIdea()
 {
     if ($this->getIdeaService()->isEmpty()) {
         return 'The selected idea cannot be found';
     }
     $data = array_merge_recursive($this->getRequest()->getPost()->toArray(), $this->getRequest()->getFiles()->toArray());
     $form = new Comment();
     $form->setData($data);
     if ($this->getRequest()->isPost() && isset($data['comment']) && $form->isValid()) {
         $formData = $form->getData();
         $this->getIdeaService()->addMessageToIdea($this->getIdeaService()->getIdea(), $formData['comment']);
         //Reset the form
         $form->get('comment')->setValue(null);
     }
     $documentForm = new CreateIdeaDocument();
     $documentForm->setData($data);
     if ($this->getRequest()->isPost() && isset($data['upload']) && $documentForm->isValid()) {
         $formData = $documentForm->getData();
         $this->getIdeaService()->addFileToIdea($this->getIdeaService()->getIdea(), $data['file'], empty($formData['document']) ? null : $formData['document']);
     }
     if ($this->getRequest()->isPost() && isset($data['status'])) {
         $idea = $this->getIdeaService()->getIdea();
         switch ($data['status']) {
             case 'open':
                 $idea->setDateComplete(null);
                 $this->getIdeaService()->updateEntity($idea);
                 break;
             case 'complete':
                 $idea->setDateComplete(new \DateTime());
                 $this->getIdeaService()->updateEntity($idea);
                 break;
         }
         if (isset($data['merge_idea'])) {
             //Handle the merge
             if ((int) $data['merge_idea'] === 0) {
                 $idea->setMainIdea([]);
                 $this->getIdeaService()->updateEntity($idea);
             } else {
                 $mainIdea = $this->getIdeaService()->findEntityById('Idea\\Idea', $data['merge_idea']);
                 $idea->setMainIdea([$mainIdea]);
                 $mainIdea->setDateUpdated(new \DateTime());
                 //Update both ideas to have the lastUpdate triggered
                 $this->getIdeaService()->updateEntity($idea);
                 $this->getIdeaService()->updateEntity($mainIdea);
             }
         }
     }
     return $this->getZfcTwigRenderer()->render('project/idea/idea', ['otherIdeas' => $this->getIdeaService()->findIdeaByCall($this->getIdeaService()->getIdea()->getCall(), $this->getServiceLocator()->get('zfcuser_auth_service')->getIdentity(), true), 'ideaService' => $this->getIdeaService(), 'documentForm' => $documentForm, 'form' => $form]);
 }