示例#1
0
文件: Entity.php 项目: uqiauto/fusio
 /**
  * Returns the PUT response
  *
  * @param \PSX\Data\RecordInterface $record
  * @param \PSX\Api\Version $version
  * @return array|\PSX\Data\RecordInterface
  */
 protected function doUpdate(RecordInterface $record, Version $version)
 {
     $appId = (int) $this->getUriFragment('app_id');
     $app = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\App')->get($appId);
     if (!empty($app)) {
         $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\App')->update(array('id' => $app->getId(), 'status' => $record->getStatus(), 'name' => $record->getName(), 'url' => $record->getUrl()));
         $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\App\\Scope')->deleteAllFromApp($appId);
         $scopes = $record->getScopes();
         if (!empty($scopes) && is_array($scopes)) {
             $this->insertScopes($appId, $scopes);
         }
         return array('success' => true, 'message' => 'App successful updated');
     } else {
         throw new StatusCode\NotFoundException('Could not find app');
     }
 }
示例#2
0
文件: Entity.php 项目: uqiauto/fusio
 /**
  * Returns the PUT response
  *
  * @param \PSX\Data\RecordInterface $record
  * @param \PSX\Api\Version $version
  * @return array|\PSX\Data\RecordInterface
  */
 protected function doUpdate(RecordInterface $record, Version $version)
 {
     $userId = (int) $this->getUriFragment('user_id');
     $user = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\User')->get($userId);
     if (!empty($user)) {
         $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\User')->update(array('id' => $user['id'], 'status' => $record->getStatus(), 'name' => $record->getName()));
         $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\User\\Scope')->deleteAllFromUser($user['id']);
         $this->insertScopes($user['id'], $record->getScopes());
         return array('success' => true, 'message' => 'User successful updated');
     } else {
         throw new StatusCode\NotFoundException('Could not find user');
     }
 }
示例#3
0
 /**
  * Returns the POST response
  *
  * @param \PSX\Data\RecordInterface $record
  * @param \PSX\Api\Version $version
  * @return array|\PSX\Data\RecordInterface
  */
 protected function doCreate(RecordInterface $record, Version $version)
 {
     $appKey = TokenGenerator::generateAppKey();
     $appSecret = TokenGenerator::generateAppSecret();
     $table = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\App');
     $table->create(array('userId' => $record->getUserId(), 'status' => $record->getStatus(), 'name' => $record->getName(), 'url' => $record->getUrl(), 'appKey' => $appKey, 'appSecret' => $appSecret, 'date' => new DateTime()));
     $appId = $table->getLastInsertId();
     // insert scopes to the app which are assigned to the user
     $this->insertDefaultScopes($appId, $record->getUserId());
     return array('success' => true, 'message' => 'App successful created');
 }