SilverStripe\SearchDataExtractor\Control\SearchDataExtractorAPIController
Synopsis
class SearchDataExtractorAPIController
extends Controller
implements
PermissionProvider
{
- // constants
- const API_PERMISSION_CODE = 'SEARCH_DATA_EXTRACTOR_ACCESS';
- const ENV_DISABLE_HTTPS = 'DISABLE_SEARCH_DATA_EXTRACTOR_HTTPS';
- // members
- private static array $exposed_core_models = ;
- private static integer $pagination_limit = 50;
- private static string $realm = 'Search Data Extractor API';
- // methods
- public HTTPResponse|null init()
- public string index()
- protected boolean validateProtocol()
- protected Member|boolean authenticateRequest()
- protected boolean validateAllowedClass()
- protected int getOffsetID()
- protected array getData()
- protected HTTPResponse error()
- public array providePermissions()
Hierarchy
Extends
- SilverStripe\Control\Controller
Implements
- SilverStripe\Security\PermissionProvider
Constants
Name | Value |
---|---|
API_PERMISSION_CODE | 'SEARCH_DATA_EXTRACTOR_ACCESS' |
ENV_DISABLE_HTTPS | 'DISABLE_SEARCH_DATA_EXTRACTOR_HTTPS' |
Members
private
- $exposed_core_models
—
array
This is used to define any core models that need to be exposed through the API, e.g. SilverStripe\Assets\File, as we cannot implement the interface directly to these classes. - $pagination_limit
—
integer
The limit of results to display per "page" of results. - $realm
—
string
The title of the pop up for when the Basic Authentication prompt is displayed.
Methods
protected
- authenticateRequest() — Helper to authenticate the request using Basic Authentication.
- error() — Helper to return an error response, ensuring the content-type is 'application/json'.
- getData() — Extract the data from the DB to surface via the API.
- getOffsetID() — Helper to get the pagination offset ID.
- validateAllowedClass() — Helper to ensure the provided class can actually be surfaced through the API.
- validateProtocol() — Helper to ensure the request is over https.
public
- index() — Entry point into the API that retrieves the data to surface as JSON.
- init() — Using this to run authentication and HTTPS checks first.
- providePermissions() — Setting up a permission code for the API.