GovtNZ\SilverStripe\SqlExplorer\SQLExplorerQueryGrid_ItemRequest
This subclass is required because the detail form requires extra actions on the edit form. While SS documentation says this is easy to do, by the model implementing getCMSActions, grid fields editor completely ignores it, and provides no way for the DataObject to define it's own behaviour, only extensions, which is undesirable for our case.
So this solution: override the _ItemRequest class of the grid field, and tell the
grid field about it. This will need to handle any custom actions.
Synopsis
class SQLExplorerQueryGrid_ItemRequest
extends GridFieldDetailForm_ItemRequest
{
- // members
- private static array $allowed_actions = ;
- private static array $url_handlers = ;
- // methods
- public void getData()
- public void errorHandler()
- protected void getDataInternal()
- protected boolean validSQL()
- protected void columnOK()
- public void export()
- public void generateExportFileData()
Hierarchy
Extends
- SilverStripe\Forms\GridField\GridFieldDetailForm_ItemRequest
Tasks
Line | Task |
---|---|
195 | consider moving separate and whether we want a header to the saved query object. |
Members
private
- $allowed_actions
- $url_handlers
Methods
protected
- columnOK()
- getDataInternal() — Actual implementation to fetch the query, check security and execute it.
- validSQL() — Determine if this SQL statement should allowed to be executed. We only support read-only queries, so it's got to start with a "select".
public
- errorHandler() — A simple error handler that is set for the SQL execution, which takes a user error and throws it as an exception. This lets us catch it and return it in the ajax response.
- export()
- generateExportFileData()
- getData() — API method to get data for ajax request. Returns an application/json response.