コード例 #1
0
 /**
  * 
  * @param array $attributes
  * @throws Exception
  * @return \conquer\oauth2\models\RefreshToken
  */
 public static function createRefreshToken(array $attributes)
 {
     static::deleteAll(['<', 'expires', time()]);
     $attributes['refresh_token'] = \Yii::$app->security->generateRandomString(40);
     $refreshToken = new static($attributes);
     if ($refreshToken->save()) {
         return $refreshToken;
     } else {
         \Yii::error(__CLASS__ . ' validation error:' . VarDumper::dumpAsString($refreshToken->errors));
     }
     throw new Exception('Unable to create refresh token', Exception::SERVER_ERROR);
 }
コード例 #2
0
ファイル: EventController.php プロジェクト: kleitz/golfleague
 /**
  * Displays a single Rule model.
  * @param integer $id
  * @return mixed
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     if ($model->load(Yii::$app->request->post()) && $model->save()) {
         return $this->redirect(['view', 'id' => $model->id]);
     } else {
         if (count($model->errors) > 0) {
             Yii::$app->session->setFlash('danger', Yii::t('igolf', 'Error(s): {0}', [VarDumper::dumpAsString($model->errors, 4, true)]));
         }
         return $this->render('view', ['model' => $model]);
     }
 }
コード例 #3
0
ファイル: FlightVoyage.php プロジェクト: niranjan2m/Voyanga
 public function saveReference($order)
 {
     $orderHasFlightVoyage = new OrderHasFlightVoyage();
     $orderHasFlightVoyage->orderId = $order->id;
     $orderHasFlightVoyage->orderFlightVoyage = $this->internalId;
     if (!$orderHasFlightVoyage->save()) {
         throw new CException(VarDumper::dumpAsString($this->attributes) . VarDumper::dumpAsString($orderHasFlightVoyage->errors));
     }
 }
コード例 #4
0
ファイル: HotelStack.php プロジェクト: niranjan2m/Voyanga
 /**
  * Function for sorting by uasort
  * @param HotelStack $a
  * @param HotelStack $b
  */
 private static function compareStacksByHotelsParams($a, $b)
 {
     if (is_object($a->getHotel()) and $a->getHotel() instanceof Hotel) {
         $valA = $a->getHotel()->getValueOfParam(self::$sortParam);
     } else {
         throw new CException('Incorrect first hotel incoming to compareness: ' . VarDumper::dumpAsString($a));
     }
     if (is_object($b->getHotel()) and $b->getHotel() instanceof Hotel) {
         $valB = $b->getHotel()->getValueOfParam(self::$sortParam);
     } else {
         throw new CException('Incorrect second hotel incoming to compareness: ' . VarDumper::dumpAsString($b));
     }
     if ($valA < $valB) {
         return -1;
     } elseif ($valA > $valB) {
         return 1;
     }
     return 0;
 }
コード例 #5
0
ファイル: Hotel.php プロジェクト: niranjan2m/Voyanga
 public function saveReference($order)
 {
     $orderHasHotel = OrderHasHotel::model()->findByAttributes(array('orderId' => $order->id, 'orderHotel' => $this->internalId));
     if (!$orderHasHotel) {
         $orderHasHotel = new OrderHasHotel();
         $orderHasHotel->orderId = $order->id;
         $orderHasHotel->orderHotel = $this->internalId;
         $orderHasHotel->save();
         if (!$orderHasHotel->save()) {
             throw new CException(VarDumper::dumpAsString($orderHasHotel->errors));
         }
     }
 }