Beispiel #1
0
 public function testSetGetUser()
 {
     $user = new User();
     $user->setId('test');
     $this->target->setUser($user);
     $this->assertEquals($this->target->getUser(), $user);
 }
Beispiel #2
0
 /**
  * Processes formular data
  * 
  * @return \Zend\View\Model\ViewModel
  */
 public function formAction()
 {
     $services = $this->getServiceLocator();
     $repository = $services->get('repositories')->get('Applications/Application');
     $mode = $this->params()->fromQuery('mode', 'new');
     $appId = $this->params()->fromQuery('id');
     $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 = $services->get('forms')->get('Applications/CommentForm');
     $form->bind($comment);
     if ($this->getRequest()->isPost()) {
         $form->setData($_POST);
         if ($form->isValid()) {
             if ('new' == $mode) {
                 $application = $repository->find($appId);
                 $application->comments->add($comment);
             }
             $viewModel->setVariable('isSaved', true);
         }
     }
     $viewModel->setVariables(array('mode' => $mode, 'identifier' => $appId, 'commentForm' => $form));
     return $viewModel;
 }