public function formAction()
    {
        $repository = $this->repositories->get('Applications/Application');
        
        $mode  = $this->params()->fromQuery('mode', 'new');
        $appId = $this->params()->fromQuery('id');
        /* @var \Applications\Entity\Application $application */
        $application = $repository->find($appId);

        $viewModel = new ViewModel();
        if ('edit' == $mode) {
            $comment = $repository->findComment($appId);
        } else {
            $comment = new Comment();
            $comment->setUser($this->auth()->getUser());
        }
        
        $this->acl($application, 'read');
        
        $form = $this->formManager->get('Applications/CommentForm');
        $form->bind($comment);
        
        if ($this->getRequest()->isPost()) {
            $form->setData($_POST);
            
            if ($form->isValid()) {
                if ('new' == $mode) {
                    $application = $repository->find($appId);
                    $application->getComments()->add($comment);
                    $application->changeStatus(
                        $application->getStatus(),
                        sprintf(
                                    /* @translate */ 'Application was rated by %s',
                                     $this->auth()->getUser()->getInfo()->getDisplayName()
                    )
                        );
                }
                $viewModel->setVariable('isSaved', true);
            }
        }
       
        $viewModel->setVariables(
            array(
            'mode' => $mode,
            'identifier' => $appId,
            'commentForm' => $form,
            )
        );
        return $viewModel;
    }
public function formAction()
    {
        $repository = $this->repositories->get('Applications/Application');
        
        $mode  = $this->params()->fromQuery('mode', 'new');
        $appId = $this->params()->fromQuery('id');
        /* @var \Applications\Entity\Application $application */
        $application = $repository->find($appId);

        $viewModel = new ViewModel();
        if ('edit' == $mode) {
            $comment = $repository->findComment($appId);
        } else {
            $comment = new Comment();
            $comment->setUser($this->auth()->getUser());
        }
        
        $this->acl($application, 'read');
        
        $form = $this->formManager->get('Applications/CommentForm');
        $form->bind($comment);
        
        if ($this->getRequest()->isPost()) {
            $form->setData($_POST);
            
            if ($form->isValid()) {
                if ('new' == $mode) {
                    $application = $repository->find($appId);
                    $application->getComments()->add($comment);
                    $application->changeStatus(
                        $application->getStatus(),
                        sprintf(
                                    /* @translate */ 'Application was rated by %s',
                                     $this->auth()->getUser()->getInfo()->getDisplayName()
                    )
                        );
                }
                $viewModel->setVariable('isSaved', true);
            }
        }
       
        $viewModel->setVariables(
            array(
            'mode' => $mode,
            'identifier' => $appId,
            'commentForm' => $form,
            )
        );
        return $viewModel;
    }
public function formAction ( ) { $ repository = $ this -> repositories -> get ( 'Applications/Application' ) ; $ mode = $ this -> params ( ) -> fromQuery ( 'mode' , 'new' ) ; $ appId = $ this -> params ( ) -> fromQuery ( 'id' ) ; /* @var \Applications\Entity\Application $application */ $ application = $ repository -> find ( $ appId ) ; $ viewModel = new ViewModel ( ) ; if ( 'edit' == $ mode ) { $ comment = $ repository -> findComment ( $ appId ) ; } else { $ comment = new Comment ( ) ; $ comment -> setUser ( $ this -> auth ( ) -> getUser ( ) ) ; } $ this -> acl ( $ application , 'read' ) ; $ form = $ this -> formManager -> get ( 'Applications/CommentForm' ) ; $ form -> bind ( $ comment ) ; if ( $ this -> getRequest ( ) -> isPost ( ) ) { $ form -> setData ( $ _POST ) ; if ( $ form -> isValid ( ) ) { if ( 'new' == $ mode ) { $ application = $ repository -> find ( $ appId ) ; $ application -> getComments ( ) -> add ( $ comment ) ; $ application -> changeStatus ( $ application -> getStatus ( ) , sprintf ( /* @translate */ 'Application was rated by %s' , $ this -> auth ( ) -> getUser ( ) -> getInfo ( ) -> getDisplayName ( ) ) ) ; } $ viewModel -> setVariable ( 'isSaved' , true ) ; } } $ viewModel -> setVariables ( array ( 'mode' => $ mode , 'identifier' => $ appId , 'commentForm' => $ form , ) ) ; return $ viewModel ; }
Processes formular data

@return \Zend\View\Model\ViewModel
Processes formular data