本文整理汇总了PHP中MainController::restEvents方法的典型用法代码示例。如果您正苦于以下问题:PHP MainController::restEvents方法的具体用法?PHP MainController::restEvents怎么用?PHP MainController::restEvents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MainController
的用法示例。
在下文中一共展示了MainController::restEvents方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restEvents
public function restEvents()
{
parent::restEvents();
// $this->onRest('post.filter.model.find.all', function($result) {
// foreach ($result as &$res) {
// if ($res['providers']['profile_photo']!="")
// $res['providers']['profile_photo'] = Yii::app()->getBaseUrl(true) ."/images/". $res['providers']['profile_photo'];
// if ($res['users']['profile_photo']!="")
// $res['users']['profile_photo'] = Yii::app()->getBaseUrl(true) ."/images/". $res['users']['profile_photo'];
// }
// return $result;
// });
}
示例2: restEvents
public function restEvents()
{
parent::restEvents();
// $this->onRest('post.filter.model.find.all', function($result) {
// foreach ($result as &$res) {
// if ($res['profile_photo']!="")
// $res['profile_photo'] = Yii::app()->getBaseUrl(true) . $res['profile_photo'];
// }
// return $result;
// });
$this->onRest('model.find', function ($model, $id) {
if (Yii::app()->user->checkAccess('manager') || Yii::app()->request->getQuery('id') == Yii::app()->user->id) {
return $model->findByPk($id);
} else {
throw new CHttpException('400', CJSON::encode("Permmission denied"));
}
});
$this->onRest('model.find.all', function ($model) {
if (Yii::app()->user->checkAccess('manager')) {
return $model->findAll();
} else {
throw new CHttpException('400', CJSON::encode("Permmission denied"));
}
});
$this->onRest('model.visible.properties', function () {
return [];
});
$this->onRest('model.hidden.properties', function () {
return ["password", "authItems.type", "authItems.type", "authItems.data", "authItems.description", "authItems.bizrule"];
});
$this->onRest('model.save', function ($model) {
if (isset($model['profile_photo']) && preg_match("/http[s]*:\\/\\//i", $data['profile_photo']) == 0) {
$filename = Helper::_saveImageFromBas64($model['profile_photo'], Yii::app()->getBasePath() . Yii::app()->params->userImages);
$model['profile_photo'] = Yii::app()->getBaseUrl(true) . Yii::app()->params->userRealImages . "{$filename}";
}
$model->key = md5(uniqid() . $model->password);
if (!$model->save()) {
throw new CHttpException('400', CJSON::encode($model->errors));
}
$model->refresh();
return $model;
});
}
示例3: restEvents
public function restEvents()
{
parent::restEvents();
// $this->onRest('post.filter.model.find.all', function($result) {
// foreach ($result as &$res) {
// if ($res['profile_photo']!="")
// $res['profile_photo'] = Yii::app()->getBaseUrl(true) . $res['profile_photo'];
// }
// return $result;
// });
$this->onRest('model.save', function ($model) {
if (isset($model['profile_photo']) && preg_match("/http[s]*:\\/\\//i", $data['profile_photo']) == 0) {
$filename = Helper::_saveImageFromBas64($model['profile_photo'], Yii::app()->getBasePath() . Yii::app()->params->salonImages);
$model['profile_photo'] = Yii::app()->getBaseUrl(true) . Yii::app()->params->salonRealImages . "{$filename}";
}
if (!$model->save()) {
throw new CHttpException('400', CJSON::encode($model->errors));
}
$model->refresh();
return $model;
});
}