示例#1
0
    $result = array('response' => $response);
    JsonView::render($result);
});
/**
 * UI COLLECTION
 */
$app->map("/{$v}/tables/:table/columns/:column/:ui/?", function ($table, $column, $ui) use($acl, $ZendDb, $params, $requestPayload, $app) {
    $TableGateway = new TableGateway($acl, 'directus_ui', $ZendDb);
    switch ($app->request()->getMethod()) {
        case "PUT":
        case "POST":
            $keys = array('table_name' => $table, 'column_name' => $column, 'ui_name' => $ui);
            $uis = to_name_value($requestPayload, $keys);
            $column_settings = array();
            foreach ($uis as $col) {
                $existing = $TableGateway->select(array('table_name' => $table, 'column_name' => $column, 'ui_name' => $ui, 'name' => $col['name']))->toArray();
                if (count($existing) > 0) {
                    $col['id'] = $existing[0]['id'];
                }
                array_push($column_settings, $col);
            }
            $TableGateway->updateCollection($column_settings);
    }
    $UiOptions = new DirectusUiTableGateway($acl, $ZendDb);
    $get_new = $UiOptions->fetchOptions($table, $column, $ui);
    JsonView::render($get_new);
})->via('GET', 'POST', 'PUT');
/**
 * Run the Router
 */
if (isset($_GET['run_api_router']) && $_GET['run_api_router']) {