Admin_CommentController::updateContentsAction PHP Method

updateContentsAction() public method

    public function updateContentsAction()
    {
        $translator = \Zend_Registry::get('container')->getService('translator');
        $this->getHelper('contextSwitch')->addActionContext('update-contents', 'json')->initContext();
        if (!SecurityToken::isValid()) {
            $this->view->status = 401;
            $this->view->message = $translator->trans('Invalid security token!');
            return;
        }
        $subject = $this->getRequest()->getParam('subject');
        $body = $this->getRequest()->getParam('body');
        $id = $this->getRequest()->getParam('id');
        $values = array('subject' => $subject, 'message' => $body);
        try {
            $comment = $this->commentRepository->find($id);
            $comment = $this->commentRepository->update($comment, $values);
            $this->commentRepository->flush();
        } catch (Exception $e) {
            $this->view->status = $e->getCode();
            $this->view->message = $e->getMessage();
            return;
        }
        $this->view->status = 200;
        $this->view->message = "succesful";
    }