2016-06-30 23:03:17 +02:00
|
|
|
<?php
|
|
|
|
use RedBeanPHP\Facade as RedBean;
|
|
|
|
|
|
|
|
class CommentController extends Controller {
|
|
|
|
const PATH = '/comment';
|
|
|
|
|
|
|
|
private $ticketId;
|
|
|
|
private $content;
|
|
|
|
|
|
|
|
public function handler() {
|
2016-07-04 02:32:34 +02:00
|
|
|
$this->requestData();
|
|
|
|
$this->storeComment();
|
2016-06-30 23:03:17 +02:00
|
|
|
|
2016-07-04 02:32:34 +02:00
|
|
|
Response::respondSuccess();
|
2016-06-30 23:03:17 +02:00
|
|
|
}
|
|
|
|
|
2016-07-04 02:32:34 +02:00
|
|
|
private function requestData() {
|
2016-06-30 23:03:17 +02:00
|
|
|
$this->ticketId = Controller::request('ticketId');
|
|
|
|
$this->content = Controller::request('content');
|
2016-07-04 02:32:34 +02:00
|
|
|
}
|
2016-06-30 23:03:17 +02:00
|
|
|
|
2016-07-04 02:32:34 +02:00
|
|
|
private function storeComment() {
|
2016-06-30 23:03:17 +02:00
|
|
|
$comment = new Comment();
|
|
|
|
$comment->setProperties(array(
|
|
|
|
'content' => $this->content
|
|
|
|
));
|
|
|
|
|
|
|
|
$ticket = Ticket::getTicket($this->ticketId);
|
2016-07-04 02:32:34 +02:00
|
|
|
$ticket->addComment($comment);
|
|
|
|
$ticket->store();
|
2016-06-30 23:03:17 +02:00
|
|
|
}
|
|
|
|
}
|