/** * COLUMNS COLLECTION */ // GET all table columns, or POST one new table column $app->map("/{$v}/tables/:table/columns/?", function ($table_name) use($ZendDb, $params, $requestPayload, $app, $acl) { $params['table_name'] = $table_name; if ($app->request()->isPost()) { /** * @todo check if a column by this name already exists * @todo build this into the method when we shift its location to the new layer */ if (!$acl->hasTablePrivilege($table_name, 'alter')) { throw new UnauthorizedTableAlterException("Table alter access forbidden on table `{$table_name}`"); } $tableGateway = new TableGateway($acl, $table_name, $ZendDb); $params['column_name'] = $tableGateway->addColumn($table_name, $requestPayload); } $response = TableSchema::getSchemaArray($table_name, $params); JsonView::render($response); })->via('GET', 'POST'); // GET or PUT one column $app->map("/{$v}/tables/:table/columns/:column/?", function ($table, $column) use($ZendDb, $acl, $params, $requestPayload, $app) { $params['column_name'] = $column; $params['table_name'] = $table; // This `type` variable is used on the client-side // Not need on server side. // @TODO: We should probably stop using it on the client-side unset($requestPayload['type']); // Add table name to dataset. @TODO more clarification would be useful // Also This would return an Error because of $row not always would be an array. foreach ($requestPayload as &$row) {