public function delete($schemaId) { $schema = $this->schemaTable->get($schemaId); if (!empty($schema)) { // check whether we have routes which depend on this schema if ($this->routesMethodTable->hasSchema($schemaId)) { throw new StatusCode\BadRequestException('Cannot delete schema because a route depends on it'); } // delete route dependencies $this->routesSchemaTable->deleteBySchema($schema['id']); $this->schemaTable->delete(array('id' => $schema['id'])); } else { throw new StatusCode\NotFoundException('Could not find schema'); } }