示例#1
0
 /**
  * @param string $identifier
  * @param string $secret
  * @param string $name
  * @param string $redirectUri
  * @return boolean
  */
 public function addNewClient($identifier, $secret, $name, $redirectUri)
 {
     $db = CommonModel::getDb();
     $transaction = $db->beginTransaction();
     try {
         $clientModel = new ClientModel();
         $clientModel->id = $identifier;
         $clientModel->secret = $secret;
         $clientModel->name = $name;
         if (!$clientModel->save()) {
             return false;
         }
         $clientProfile = new ClientProfileModel();
         $clientProfile->client_id = $clientModel->id;
         $clientProfile->redirect_uri = $redirectUri;
         $clientProfile->save();
         $transaction->commit();
         return true;
     } catch (\Exception $e) {
         $transaction->rollBack();
         return false;
     }
 }