示例#1
0
 /**
  * To update/edit a blog post
  *
  * @parmam void
  * @return ViewModel
  * @throws AccessProhibitedException
  **/
 public function editAction()
 {
     $this->_checkAcl('edit');
     $request = $this->getRequest();
     $post = $this->_postService->getFromId($request->getQuery('id'));
     $categoryService = new CategoryService($this->_em);
     $form = new PostForm();
     $form->bind($post);
     $form->setCategoryList($categoryService->getAll());
     $this->_postService->setForm($form);
     if ($request->isPost()) {
         $this->_postService->save($request->getPost());
     }
     return new ViewModel(array('form' => $form, 'post' => $post, 'messages' => $this->_postService->getMessages(PostService::MSG_NOTICE), 'errors' => $this->_postService->getMessages(PostService::MSG_ERROR)));
 }