Пример #1
0
 public function testDelete()
 {
     $messageMapper = new MessageMapper();
     $messageMapper->setId(1);
     $messageMapper->deleteMessage();
     $this->assertEquals(new Message(), $messageMapper->selectMessage());
 }
Пример #2
0
                    $options = array('indent' => '     ', 'addDecl' => false, XML_SERIALIZER_OPTION_RETURN_RESULT => true, "defaultTagName" => "message");
                    $serializer = new XML_Serializer($options);
                    Rest::sendResponse(200, $serializer->serialize($messagesArray), 'application/xml');
                }
            }
        } else {
            Rest::sendResponse(204);
        }
        break;
    case 'post':
        try {
            $message = new Message();
            $data_message = $http->getRequestVars();
            $messageObject = initObject($data_message, $message, true);
            if (!emptyObject($messageObject)) {
                $messageMapper = new MessageMapper();
                if ($messageMapper->insertMessage($messageObject)) {
                    Rest::sendResponse(200);
                }
            } else {
                throw new InvalidArgumentException('Need arguments to POST data !');
            }
        } catch (InvalidArgumentException $e) {
            $e->getMessage();
            exit;
        }
        break;
    default:
        Rest::sendResponse(501);
        break;
}
Пример #3
0
            Rest::sendResponse(204);
        }
        break;
    case 'delete':
        $messageMapper = new \MessageMapper();
        if ($messageMapper->deleteMessage()) {
            Rest::sendResponse(200);
        }
        break;
    case 'put':
        try {
            $message_ = new Message();
            $data_message_ = $http->getRequestVars();
            $messageObject = initObject($data_message_, $message_, true);
            if (!emptyObject($messageObject)) {
                $messageMapper = new \MessageMapper();
                if ($messageMapper->updateMessage($messageObject)) {
                    Rest::sendResponse(200);
                }
            } else {
                throw new InvalidArgumentException('Need arguments to UPDATE data !');
            }
        } catch (InvalidArgumentException $e) {
            print $e->getMessage();
            exit;
        }
        break;
    default:
        Rest::sendResponse(501);
        break;
}