示例#1
0
 public function getDeletedTaskLog(Request $request)
 {
     if ($request->isPost()) {
         $requestReport = $request->getData();
         $report = $this->getFactory()->buildReport();
         $messageCollector = $report->getMessageCollector();
         if ($report->validate()) {
             $tasks = $report->findDeleted()->getTasks();
             return $this->response(true, array(), $tasks);
         } else {
             return $this->response(false, $report->getMessageCollector()->getErrors());
         }
     }
     return $this->response(false, array('Invalid request method used!'));
 }
示例#2
0
 public function changeTaskStatus(Request $request)
 {
     if ($request->isPost()) {
         $requestTask = $request->getData();
         if (!isset($requestTask->id)) {
             return $this->response(false, array('No id was specified.'));
         }
         $task = $this->getFactory()->buildTask();
         $taskExistsSpecification = new TaskExists();
         $taskExistsSpecification->setRepository($task->getRepository());
         $task->addSpecification($taskExistsSpecification);
         $task->addSpecification(new TaskHasValidStatus());
         $messageCollector = $task->getMessageCollector();
         $task->setId(new Id($requestTask->id));
         if (!isset($requestTask->status)) {
             return $this->response(false, array('No status was specified.'));
         } else {
             try {
                 $status = new Status($requestTask->status);
                 $task->setStatus($status);
             } catch (\Exception $ex) {
                 return $this->response(false, array('Invalid status was specified.'));
             }
         }
         if ($task->validate()) {
             $task->save();
             $messageCollector->pushMessage('Status changed.');
             return $this->response(true, $messageCollector->getMessages());
         } else {
             return $this->response(false, $task->getMessageCollector()->getErrors());
         }
     } else {
         return $this->response(false, array('Invalid request method used!'));
     }
 }