Lifecycles
Every entity has a lifecycle. The lifecycle is a series of events that are triggered during the life of the entity. The events are:
onCreate
onUpdate
onDelete
It might be useful to undertake certain actions when an entity is created, updated, or deleted. The ORM provides a way to do this. It is called a lifecycle.
It is also possible to modify data before it is saved to the database.
The hook into the lifecycle of an entity is done by implementing the Swift\Orm\Behavior\LifecycleInterface
.
The is no limit to the number of lifecycles that can be implemented.
#
UsageA possible use case could be to add a spamfilter to the movie entity.