title |
---|
Observers |
Entry observers extend base observers.
Observers{.link}
Entry entry
model observers are typically generated automatically when using make:stream
Streams CLI command.
CLI Commands{.link}
<?php namespace Anomaly\ExampleModule\Example;
use Anomaly\Streams\Platform\Entry\EntryObserver;
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
class ExampleObserver extends EntryObserver
{
//
}
Entry model observers are registered automatically via class transformation.
You can register additional observers if needed from your addon service provider.
Service Providers{.link}
<?php namespace Anomaly\ExampleTheme;
use Anomaly\ExampleModule\Example\ExampleModel;
use Anomaly\ExampleTheme\Observer\ExampleObserver;
use Anomaly\Streams\Platform\Addon\AddonServiceProvider;
class ExampleThemeServiceProvider extends AddonServiceProvider
{
public function register()
{
//
}
public function boot()
{
ExampleModel::observe(ExampleObserver::class);
}
}
All entry models support the eloquent model observer events and also add a couple entry model only events.
This event is fired just before the entry
is created.
public function creating(EntryInterface $entry)
{
// Do stuff.
parent::creating($entry);
}
This event is fired just after the entry
is created.
public function created(EntryInterface $entry)
{
// Do stuff.
parent::created($entry);
}
This event is fired just before the entry
is updated.
public function updating(EntryInterface $entry)
{
// Do stuff.
parent::updating($entry);
}
This event is fired just after the entry
is updated.
public function updated(EntryInterface $entry)
{
// Do stuff.
parent::updated($entry);
}
This event is fired just after the table corresponding to entry
is mass updated.
public function updatedMultiple(EntryInterface $entry)
{
// Do stuff.
parent::updatedMultiple($entry);
}
This event is fired just before the entry
is saved.
public function saving(EntryInterface $entry)
{
// Do stuff.
parent::saving($entry);
}
This event is fired just after the entry
is saved.
public function saved(EntryInterface $entry)
{
// Do stuff.
parent::saved($entry);
}
This event is fired just before the entry
is deleted.
public function deleting(EntryInterface $entry)
{
// Do stuff.
parent::deleting($entry);
}
This event is fired just after the entry
is deleted.
public function deleted(EntryInterface $entry)
{
// Do stuff.
parent::deleted($entry);
}
This event is fired just after the table corresponding to entry
is mass deleted.
public function deletedMultiple(EntryInterface $entry)
{
// Do stuff.
parent::deletedMultiple($entry);
}
This event is fired just before the entry
is restored.
public function restoring(EntryInterface $entry)
{
// Do stuff.
parent::restoring($entry);
}
This event is fired just after the entry
is restored.
public function restored(EntryInterface $entry)
{
// Do stuff.
parent::restored($entry);
}