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