Event Categories
There are type primary different types of events in Movable Type:
- Application-level Events
- Object-level Events
Application-level Events
Application events occur at specific points during the life cycle of the Movable Type. Application callbacks include those that are fired during publishing, during backup and restore operations, in our Atom and XML-RPC APIs and more.
For a complete listing of Application Callbacks, consult the Movable Type Callbacks Reference.
Object-level Events
Object-level events are automatically associated with every single object type in Movable Type and are fired just prior to and after that object is modified in the database. For example, all objects expose the following standard subroutines:
- save
- load
- load_iter
- remove
- remove_all
Events are fired for each of the above operations just prior and immediately following them being called by a developer. Developers can register callbacks for the following events, which hopefully will correlate logically to their corresponding events:
- MT::ObjectName::pre_save
- MT::ObjectName::post_save
- MT::ObjectName::pre_load
- MT::ObjectName::post_load
- MT::ObjectName::pre_remove
- MT::ObjectName::pre_remove_all
- MT::ObjectName::post_remove_all
A couple of notes:
pre_load
andpost_load
callbacks are invoked for each object when a developer invokes theload_iter
method on an objectno event is fired for
post_remove
You will need to replace “MT::ObjectName” with the package name for the object in question. For example, the pre_save
event for the MT::Entry object is: MT::Entry::pre_save
.
Note: Developers creating their own object types do not need to create or fire these events. That is handled for you by Movable Type’s data abstraction layer.