当前位置: 首页>>代码示例>>PHP>>正文


PHP MainController::restEvents方法代码示例

本文整理汇总了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;
     //        });
 }
开发者ID:mudiman,项目名称:yiirestintegrated,代码行数:13,代码来源:WorkersController.php

示例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;
     });
 }
开发者ID:mudiman,项目名称:yiirestintegrated,代码行数:43,代码来源:UsersController.php

示例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;
     });
 }
开发者ID:mudiman,项目名称:yiirestintegrated,代码行数:22,代码来源:ProvidersController.php


注:本文中的MainController::restEvents方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。