Пример #1
0
 public function testDelete()
 {
     $pictureMapper = new PictureMapper();
     $pictureMapper->setId(1);
     $pictureMapper->deletePicture();
     $this->assertEquals(new Picture(), $pictureMapper->selectPicture());
 }
Пример #2
0
        }
        break;
    case 'delete':
        $picture_ = new Picture();
        $pictureMapper = new \PictureMapper();
        if ($pictureMapper->deletePicture()) {
            Rest::sendResponse(200);
        }
        break;
    case 'put':
        try {
            $picture_ = new Picture();
            $data_picture_ = $http->getRequestVars();
            $pictureObject = initObject($data_picture_, $picture_, true);
            if (!emptyObject($pictureObject)) {
                $pictureMapper = new \PictureMapper();
                if ($pictureMapper->updatePicture($pictureObject)) {
                    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;
}
 public function getPictures(PictureMapper $pictureMapper_)
 {
     $picturesObjects = $pictureMapper_->selectPicture(true);
     return $picturesObjects;
 }
Пример #4
0
                    $options = array('indent' => '     ', 'addDecl' => false, XML_SERIALIZER_OPTION_RETURN_RESULT => true, "defaultTagName" => "picture");
                    $serializer = new XML_Serializer($options);
                    Rest::sendResponse(200, $serializer->serialize($picturesArray), 'application/xml');
                }
            }
        } else {
            Rest::sendResponse(204);
        }
        break;
    case 'post':
        try {
            $picture = new Picture();
            $data_picture = $http->getRequestVars();
            $pictureObject = initObject($data_picture, $picture, true);
            if (!emptyObject($pictureObject)) {
                $pictureMapper = new PictureMapper();
                if ($pictureMapper->insertPicture($pictureObject, array(), true)) {
                    Rest::sendResponse(200);
                }
            } else {
                throw new InvalidArgumentException('Need arguments to POST data !');
            }
        } catch (InvalidArgumentException $e) {
            $e->getMessage();
            exit;
        }
        break;
    default:
        Rest::sendResponse(501);
        break;
}