本文整理汇总了PHP中Response::ok方法的典型用法代码示例。如果您正苦于以下问题:PHP Response::ok方法的具体用法?PHP Response::ok怎么用?PHP Response::ok使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Response
的用法示例。
在下文中一共展示了Response::ok方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: inmueblesDestacados
private function inmueblesDestacados()
{
$inmuebles = Inmueble::findDestacados();
$arrInmuebles = array();
foreach ($inmuebles as $inm) {
array_push($arrInmuebles, $inm->toArray());
}
Response::ok(CJSON::encode($arrInmuebles));
}
示例2: processGet
public function processGet()
{
$list = Product::model()->findAll();
$items = array();
foreach ($list as $p) {
array_push($items, array("id" => $p->id, "name" => $p->name, "description" => $p->description, "images" => $p->images));
}
Response::ok(CJSON::encode(array("version" => "xxxxxxxxxxxxxxxxxxx", "items" => $items)));
}
示例3: postDevice
public function postDevice()
{
if (Input::has('device_type') && Input::has('token')) {
$deviceType = Input::get('device_type');
$token = Input::get('token');
$user = Auth::getUser();
$user->device_type = $deviceType;
$user->device_token = $token;
$user->save();
return Response::ok($user);
} else {
return Response::error('Missing parameters');
}
}
示例4: postRegister
public function postRegister()
{
if (Input::has('email') && Input::has('password') && Input::has('name')) {
$email = Input::get('email');
$password = Input::get('password');
$name = Input::get('name');
$user = $this->registerService->register($email, $name, $password);
if ($user === NULL) {
return Response::error('Failed to register');
} else {
return Response::ok($user);
}
} else {
return Response::error('Missing parameters');
}
}
示例5: createNotification
/**
* Displays a particular model.
* @param integer $id the ID of the model to be displayed
*/
private function createNotification()
{
$transaction = Yii::app()->db->beginTransaction();
try {
$ntf = new Notification();
$ntf->customSetAttributes($this->arguments);
if ($ntf->save()) {
$transaction->commit();
Response::ok(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_EXITO, "message" => "notificacion con id = {$ntf->id} ingresada con exito")));
} else {
$transaction->rollback();
Response::ok(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_FALLA, "message" => $ntf->getErrors())));
}
} catch (\Exception $e) {
$transaction->rollback();
Yii::log($e->getMessage(), DBLog::LOG_LEVEL_ERROR);
Response::error(CJSON::encode(array("result" => Constants::RESULTADO_OPERACION_FALLA, "message" => Yii::app()->params["httpErrorCode500Message"])));
}
}
示例6: deleteIndex
public function deleteIndex()
{
$user = Auth::getUser();
if (Input::has('id')) {
$friendUser = $this->meService->getUser(Input::get('id'));
if ($friendUser === null) {
return Response::error('Invalid friend id');
}
$response = $this->meService->deleteFriendship($user, $friendUser);
if ($response !== null) {
return Response::ok($response);
} else {
return Response::error('Failed to delete friendship');
}
} else {
return Response::error('Missing parameters');
}
}
示例7: ok
public function ok()
{
$r = Response::ok();
$this->assertEquals(200, $r->status);
}
示例8: actionGetAllEvents
public function actionGetAllEvents()
{
$out = array();
try {
$events = Event::model()->findAll("user_id=:userId", array("userId" => Yii::app()->user->id));
foreach ($events as $e) {
$item = array('id' => $e->id, 'title' => $e->title, 'url' => Yii::app()->baseUrl . '/index.php/event/' . $e->id, 'class' => 'event-important', 'start' => $e->start . '000', 'end' => $e->end . '000');
array_push($out, $item);
}
Response::ok(CJSON::encode(array('success' => 1, 'result' => $out)));
} catch (Exception $exc) {
Yii::log($exc->getMessage(), DBLog::LOG_LEVEL_ERROR);
Response::error(CJSON::encode(array("result" => "error", "message" => Yii::app()->params["httpErrorCode500Message"])));
}
}
示例9: actionGetPendingNotifications
public function actionGetPendingNotifications()
{
Response::ok(CJSON::encode(Notification::model()->findAll('id_estado_notificacion=:idEstado', array("idEstado" => 1))));
}
示例10: processGet
public function processGet()
{
Response::ok(CJSON::encode(Brand::model()->findAll()));
}