示例#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\\Routes')->create(array('methods' => $record->getMethods(), 'path' => $record->getPath(), 'controller' => 'Fusio\\Impl\\Controller\\SchemaApiController', 'config' => $record->getConfig()));
     // get last insert id
     $routeId = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Routes')->getLastInsertId();
     // insert dependency links
     $this->routesDependencyManager->insertDependencyLinks($routeId, $record->getConfig());
     // lock dependencies
     $this->routesDependencyManager->lockExistingDependencies($routeId);
     return array('success' => true, 'message' => 'Route 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)
 {
     $routeId = (int) $this->getUriFragment('route_id');
     $route = $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Routes')->get($routeId);
     if (!empty($route)) {
         $this->tableManager->getTable('Fusio\\Impl\\Backend\\Table\\Routes')->update(array('id' => $route->getId(), 'methods' => $record->getMethods(), 'path' => $record->getPath(), 'controller' => 'Fusio\\Impl\\Controller\\SchemaApiController', 'config' => $record->getConfig()));
         // remove all dependency links
         $this->routesDependencyManager->removeExistingDependencyLinks($route->getId());
         // unlock dependencies
         $this->routesDependencyManager->unlockExistingDependencies($route->getId());
         // insert dependency links
         $this->routesDependencyManager->insertDependencyLinks($route->getId(), $record->getConfig());
         // lock dependencies
         $this->routesDependencyManager->lockExistingDependencies($route->getId());
         return array('success' => true, 'message' => 'Routes successful updated');
     } else {
         throw new StatusCode\NotFoundException('Could not find route');
     }
 }