Events
Events of models
Fired by Hubleto\Framework\Model from the callbacks onBefore* / onAfter*. A listener receives the model and the data:
| Event | Arguments | When |
|---|---|---|
onBeforeValidate |
$model, $record |
Before a record is validated. |
onAfterValidate |
$model, $record |
After validation. |
onModelBeforeCreate |
$model, $record |
Before a record is inserted. |
onModelAfterCreate |
$model, $savedRecord |
After a record was inserted. |
onModelBeforeUpdate |
$model, $record |
Before a record is updated. |
onModelAfterUpdate |
$model, $originalRecord, $savedRecord |
After a record was updated. |
onModelBeforeDelete |
$model, $id |
Before a record is deleted. |
onModelAfterDelete |
$model, $id |
After a record was deleted. |
onModelAfterLoadRecord |
$model, $record |
A single record was loaded. |
onModelAfterLoadRecords |
$model, $records |
A list of records was loaded. |
Events of models.
public function onModelAfterUpdate(Model $model, array $originalRecord, array $savedRecord): void
{
if (!($model instanceof \Hubleto\App\Community\Deals\Models\Deal)) return;
// react to the change of a deal
}
Events of the core and controllers
| Event | Arguments | When |
|---|---|---|
onCoreAfterBootstrap |
$loader |
The loader was created. |
onCoreAfterInit |
$loader |
All services and apps were initialized. |
onControllerBeforeInit |
$controller |
Before init() of a controller. |
onControllerBeforePrepareView |
$controller |
Before prepareView(). |
onControllerAfterPrepareView |
$controller |
After prepareView(). |
onControllerSetView |
$controller, $view |
A view was assigned to the controller. |
Events of the core.
Events of apps
| Event | Fired by | Arguments | When |
|---|---|---|---|
onMailReceived |
Mail |
the mail, the attachments | A message was downloaded from an account. |
Events of apps.
Your own events
Any code can fire its own event:
$this->eventManager()->fire('onCarReturned', [$car, $mileage]);
Register listeners for it with addEventListener('onCarReturned', $listener). Prefix the names of your events with on and a noun that identifies your app, and document the arguments, as above.
