CoolCMS API

ApiClientKeyFormTrait

Form of one key of an application with Api access (`Admin:System:ApiClient`, `addKey` / `editKey`).

Fields: label (optional, at most 100 characters) and expiry (<input type=datetime-local>, optional, in the future; empty = the key is valid until someone revokes it). The "first key" section of the new application form carries the same two fields (addApiClientKeyFields()).

IMPORTANT: after addKey the readable key is handed over once to the keys page (ApiClientKeyHandover, reason issued) and the redirect always goes there; elsewhere the key would not be shown and would be lost.

Write gate: ApiClientPresenter::formSubmitPrivilege() (addKey → issueKey, editKey → updateKey).

Table of Contents

Constants

KEY_DATETIME_LOCAL_FORMAT  : string = 'Y-m-d\TH:i'
Value format of `<input type=datetime-local>` (no seconds, see {@see StrictDateInput}).

Methods

createComponentKeyForm()  : Form
addApiClientKeyFields()  : void
Adds the key label and expiry, shared by the key form and the "first key" section of a new application. Expiry is a strict `datetime-local` ({@see StrictDateInput}) in the future (the Api checks the same).
reportApiClientKeyFormError()  : void
Reports an Api error: `VALIDATION_FAILED` goes to the field named by `data.field` (`keyLabel`, `keyExpiresAt`; the key limit `keys` as a form error above the fields), others as a flash message.
saveApiClientKeyForm()  : bool

Constants

KEY_DATETIME_LOCAL_FORMAT

Value format of `<input type=datetime-local>` (no seconds, see {@see StrictDateInput}).

private string KEY_DATETIME_LOCAL_FORMAT = 'Y-m-d\TH:i'

Methods

addApiClientKeyFields()

Adds the key label and expiry, shared by the key form and the "first key" section of a new application. Expiry is a strict `datetime-local` ({@see StrictDateInput}) in the future (the Api checks the same).

private addApiClientKeyFields(Form $form) : void
Parameters
$form : Form

reportApiClientKeyFormError()

Reports an Api error: `VALIDATION_FAILED` goes to the field named by `data.field` (`keyLabel`, `keyExpiresAt`; the key limit `keys` as a form error above the fields), others as a flash message.

private reportApiClientKeyFormError(Result $result, Form $form) : void
Parameters
$result : Result
$form : Form

saveApiClientKeyForm()

private saveApiClientKeyForm(ArrayHash<string|int, mixed> $values, Form $form) : bool
Parameters
$values : ArrayHash<string|int, mixed>
$form : Form
Return values
bool
On this page

Search results