[Ivan Diaz] - Ticket comment WIP [skip ci]

This commit is contained in:
Ivan Diaz 2016-06-30 18:03:17 -03:00
parent e039162025
commit ea65ea35d1
4 changed files with 53 additions and 1 deletions

View File

@ -1,9 +1,11 @@
<?php
include 'ticket/create.php';
include 'ticket/comment.php';
$ticketControllers = new ControllerGroup();
$ticketControllers->setGroupPath('/ticket');
$ticketControllers->addController(new CreateController);
$ticketControllers->addController(new CommentController);
$ticketControllers->finalize();

View File

@ -0,0 +1,45 @@
<?php
use RedBeanPHP\Facade as RedBean;
class CommentController extends Controller {
const PATH = '/comment';
private $ticketId;
private $content;
public function handler() {
/*
//$this->storeComment();
$ticket = RedBean::load('tickets', Controller::request('ticketId'));
$comment = RedBean::dispense('comments');
$comment->content = Controller::request('content');
$ticket->ownCommentsList[] = $comment;
RedBean::store($ticket);
$ticket = RedBean::load('tickets', Controller::request('ticketId'));
$string = "";
$string += count($ticket->ownCommentsList);
foreach( $ticket->ownCommentsList as $comment2 ) {
}*/
}
private function storeComment() {
$this->ticketId = Controller::request('ticketId');
$this->content = Controller::request('content');
$ticket = Ticket::getTicket($this->ticketId);
$comment = new Comment();
$comment->setProperties(array(
'content' => $this->content
//'ticket' => $ticket->getBeanInstance()
));
$ticket->getBeanInstance()->ownCommentsList = [$comment->getBeanInstance()];
$ticket->store();
$ticket = Ticket::getTicket($this->ticketId);
Response::respondError(count($ticket->ownCommentsList));
}
}

View File

@ -1,9 +1,10 @@
<?php
use RedBeanPHP\Facade as RedBean;
class CreateController extends Controller {
const PATH = '/create';
private $title ;
private $title;
private $content;
private $departmentId;
private $language;

View File

@ -20,6 +20,10 @@ class Ticket extends DataStore {
);
}
public static function getTicket($value, $property = 'id') {
return parent::getDataStore($value, $property);
}
protected function getDefaultProps() {
return array();
}