NotificationProducerTrait
Mechanics of creating a notification in the admin bell.
When and with which type/id to notify is decided by the ...Data method of the concrete presenter; this trait only
writes the row. Pattern ReservationPresenter::notifyReservationCreated():
- best-effort: an error is logged, the finished operation is not broken;
receiverUserId = null: the bell filters onlyread = 0, so every administrator sees it;itemId= id of the foreign record, the click-through is built byNotificationTargetResolverfrom the type;- a missing / inactive type is silently skipped.
Dependencies come through #[Inject] (presenter), not the constructor, so host presenters keep their signature and
tests that build them by hand stay valid (there the best-effort notification falls into catch and creates nothing).
Table of Contents
Properties
Methods
- createdIdForNotification() : int|null
- Id of a newly created record from the `internalActionSave()` response, or `null` when nothing should be notified: update (`$data` had the id), failure, or a call from the admin.
- produceNotification() : void
Properties
$notificationManager
public
NotificationManager
$notificationManager
Attributes
- #[Inject]
$notificationTypeManager
public
NotificationTypeManager
$notificationTypeManager
Attributes
- #[Inject]
Methods
createdIdForNotification()
Id of a newly created record from the `internalActionSave()` response, or `null` when nothing should be notified: update (`$data` had the id), failure, or a call from the admin.
private
createdIdForNotification(array<string, mixed> $data, array<string, mixed> $response) : int|null
Parameters
- $data : array<string, mixed>
-
payload before saving
- $response : array<string, mixed>
-
response of
internalActionSave()
Return values
int|nullproduceNotification()
private
produceNotification(string $typeKey, int $itemId, string $text) : void
Parameters
- $typeKey : string
- $itemId : int
- $text : string