示例#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)
 {
     $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');
     }
 }
示例#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)
 {
     $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');
     }
 }