9.10. Plugins

Plugins can be added to the ORM layer through the Xyster_Orm instance which holds a plugin broker.

$plugin = new MyOrmPlugin;

There are other plugin-related methods available on Xyster_Orm.

The methods of these plugins are called before and after certain events that occur to entities.

9.10.1. Plugins Included in the Release

Xyster includes a plugin for ACL registration and one for audit trail logging in its default distribution. Xyster_Orm_Plugin_Acl

The first plugin included in the framework release is the Xyster_Orm_Plugin_Acl; responsible for registering entities that implement Zend_Acl_Resource_Interface in a Zend_Acl.

$acl = new Xyster_Acl;
$plugin = new Xyster_Orm_Plugin_Acl($acl);

When an entity is loaded from the data store or pulled from the secondary cache, the ACL plugin adds it to the Zend_Acl provided to it if the entity has not already been added. Using this plugin lets the developer omit checking the ACL for the presence of an entity and adding it if absent. Xyster_Orm_Plugin_Log

The second plugin included in the framework release is the Xyster_Orm_Plugin_Log; responsible for writing entity events to an audit trail.

$log = new Zend_Log(/* with your options here */);
$useAuth = true; /* whether to ask Zend_Auth who is authenticated */
$plugin = new Xyster_Orm_Plugin_Log($log, $useAuth);

When an entity is deleted, inserted, or updated, the plugin sends an entry to the Zend_Log at the information level (Zend_Log::INFO). As demonstrated above, the plugin can optionally get the current authenticated identity from Zend_Auth. This plugin is useful for keeping security records of entity change events.