richardhj / contao-model-events
Installs: 252
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 0
Type:contao-module
Requires
- php: ^7.1
- contao/core-bundle: ^4.4
- symfony/event-dispatcher: ^4.3
This package is auto-updated.
Last update: 2024-10-11 21:51:44 UTC
README
This extension provides the DispatchModelEventsTrait
that makes the following events available for your custom model:
Events implemented
PrePersistModelEvent
Triggered before persisting the model in the database. You can access the Model
with the current data and the Model
with the original data.
Row data can be modified at this point, when using setData()
.
PostPersistModelEvent
Triggered after persisting the model in the database. You can access the Model
with the current data and the Model
with the original data.
DeleteModelEvent
Triggered after the model has been deleted successfully. You can access the Model
instance.
Usage
Implement the Trait in your custom model
use Contao\Model; class MyTableModel extends Model { use Contao\Model\DispatchModelEventsTrait; /** * Table name * * @var string */ protected static $strTable = 'tl_my_table'; }
From now on, the above mentioned events get triggered on any save()
and delete()
action.