/** * 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'); }
/** * 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'); } }
/** * 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'); }
/** * 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'); } }