示例#1
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)
 {
     $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Action')->create(array('status' => Action::STATUS_ACTIVE, 'name' => $record->getName(), 'class' => $record->getClass(), 'config' => $record->getConfig()->getRecordInfo()->getData(), 'date' => new \DateTime()));
     return array('success' => true, 'message' => 'Action successful created');
 }
示例#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
文件: 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');
     }
 }
示例#4
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)
 {
     $connectionId = (int) $this->getUriFragment('connection_id');
     $connection = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Connection')->get($connectionId);
     if (!empty($connection)) {
         $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Connection')->update(array('id' => $connection->getId(), 'name' => $record->getName(), 'class' => $record->getClass(), 'config' => $record->getConfig()->getRecordInfo()->getData()));
         return array('success' => true, 'message' => 'Connection successful updated');
     } else {
         throw new StatusCode\NotFoundException('Could not find connection');
     }
 }
示例#5
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)
 {
     $scopeTable = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Scope');
     $scopeTable->create(array('name' => $record->getName()));
     // insert routes
     $scopeId = $scopeTable->getLastInsertId();
     $this->insertRoutes($scopeId, $record->getRoutes());
     return array('success' => true, 'message' => 'Scope successful created');
 }
示例#6
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)
 {
     $schemaTable = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Schema');
     $schemaTable->create(array('status' => Schema::STATUS_ACTIVE, 'name' => $record->getName(), 'source' => $record->getSource(), 'cache' => $this->schemaParser->parse($record->getSource(), $record->getName())));
     return array('success' => true, 'message' => 'Schema successful created');
 }
示例#7
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)
 {
     $schemaId = (int) $this->getUriFragment('schema_id');
     $schema = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Schema')->get($schemaId);
     if (!empty($schema)) {
         $this->checkLocked($schema);
         $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Schema')->update(array('id' => $schema['id'], 'name' => $record->getName(), 'source' => $record->getSource(), 'cache' => $this->schemaParser->parse($record->getSource(), $record->getName())));
         return array('success' => true, 'message' => 'Schema successful updated');
     } else {
         throw new StatusCode\NotFoundException('Could not find schema');
     }
 }
示例#8
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)
 {
     $scopeId = (int) $this->getUriFragment('scope_id');
     $scope = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Scope')->get($scopeId);
     if (!empty($scope)) {
         $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Scope')->update(array('id' => $scope['id'], 'name' => $record->getName()));
         $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Scope\\Route')->deleteAllFromScope($record->getId());
         $this->insertRoutes($record->getId(), $record->getRoutes());
         return array('success' => true, 'message' => 'Scope successful updated');
     } else {
         throw new StatusCode\NotFoundException('Could not find scope');
     }
 }
示例#9
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');
 }