-
Notifications
You must be signed in to change notification settings - Fork 52
Events
Mark Wales edited this page Jan 12, 2016
·
1 revision
Mappers have a registerEvent($event, $callback)
method which allows you to hook into various events:
initializing
initialized
store
stored
creating
created
updating
updated
deleting
deleted
For example, say you're using Elasticsearch, you could setup a listener in your repository:
$search = app()->make("App\Search\SearchInterface");
$this->mapper->registerEvent("stored", function ($entity) use($search) {
$search->index($entity);
});
$this->mapper->registerEvent("deleting", function ($entity) use ($search) {
$search->delete($entity);
});