NotificationFormTrait
Add/edit form of a notification.
The skeleton comes from BasePresenter::createForm(). The entity is
flat. notificationTypeId is a select (NotificationTypeManager), receiverUserId is a User
Picker (hidden), status is 1 success / 0 error (legacy values).
read (notification opened) and shown (notification displayed in a list) are the only bool
columns of the table; they are edited as toggles in the form header (.admin-status-toggle--muted).
Table of Contents
Constants
- NOTIF_DT_FORMAT : mixed = 'Y-m-d\TH:i'
- Value format of `<input type=datetime-local>`.
Methods
- createComponentEditForm() : Form
- prepareNotificationTypeOptions() : array<int, string>
- Returns notification type options as `id => name` (current language, falling back to the first non-empty name).
- saveNotificationForm() : bool
- setNotificationFormDefaults() : void
- tr() : string
- Translates a key in the form domain to a final string (fields with `setTranslator(null)`).
Constants
NOTIF_DT_FORMAT
Value format of `<input type=datetime-local>`.
private
mixed
NOTIF_DT_FORMAT
= 'Y-m-d\TH:i'
Methods
createComponentEditForm()
protected
createComponentEditForm() : Form
Return values
FormprepareNotificationTypeOptions()
Returns notification type options as `id => name` (current language, falling back to the first non-empty name).
private
prepareNotificationTypeOptions() : array<int, string>
The code list is held by NotificationTargetResolver, so the form select, the grid filter and the click-through targets read the same data (and one query).
Return values
array<int, string>saveNotificationForm()
private
saveNotificationForm(ArrayHash<string|int, mixed> $values) : bool
Parameters
- $values : ArrayHash<string|int, mixed>
Return values
boolsetNotificationFormDefaults()
private
setNotificationFormDefaults(Form $form) : void
Parameters
- $form : Form
tr()
Translates a key in the form domain to a final string (fields with `setTranslator(null)`).
private
tr(string $key) : string
Parameters
- $key : string