dev-master
9999999-dev http://carpe-hora.github.com/AuditableBehavior/AuditableBehavior is a propel behavior to track and record changes in your propel models.
MIT
The Requires
- php >=5.2.4
- propel/propel1 >=1.6.4
behavior propel blameable auditable
Wallogit.com
2017 © Pedro Peláez
AuditableBehavior is a propel behavior to track and record changes in your propel models.
Add the behavior to your database schema :, (*2)
``` xml
``` php <?php $auditable = new Auditable(); $auditable->setName('audit'); $auditable->save(); // and now access audit trail $auditable->countActivity(); foreach ($auditable->getLastActivity() as $activity) { echo $activity->getLabel() . '<br />'; } // will result in "CREATE<br />"
Install the behavior in your vendor directory, (*4)
``` bash $ git submodule add git://github.com/Carpe-Hora/AuditableBehavior.git lib/vendor/AuditableBehavior, (*5)
add following to your ```propel.ini``` file: ``` ini propel.behavior.auditable.class = lib.vendor.AuditableBehavior.src.AuditableBehavior
Declare behavior for the whole database in your config/schema.xml, (*6)
``` xml
or for a table only ``` xml <database name="propel" defaultIdMethod="native" package="lib.model"> <table name="my_table"> <column name="id" type="INTEGER" required="true" primaryKey="true" autoIncrement="true" /> <behavior name="auditable" /> </table> </database>
Following paramters are available :, (*8)
This behavior create an activity table and log activity for auditableed object., (*9)
To achieve this goal, method logActivity($label, $con=null) is called on postHooks., (*10)
This method create a new MonitorActivity with following parameters:, (*11)
auditable_label corresponding value for CREATE, UPDATE or DELETEauditable_object_class corresponding object classauditable_object_pk corresponding object primary keygetLastActivity($number=10, $label=null, $con=null) return the recent object related activity.logActivity($label, $con=null) create an activity entry for $labelcountActivity($label = null, $con=null) count related activityisAudited() is the current objcet auditableing its activitydisableLocalAudit() temporary remove auditableing activity for this objectenableLocalAudit() temporary force auditableing activity for this objectgetActivityCriteria get a criteria to filter activity against this objectand both static methods, (*12)
disableAudit() disable auditableing activity globaly.enableAudit() enable auditableing activity globaly.filterByObject($auditableedObject) filter query for $auditableObject related activity.getRelatedObject() return the activity related object.AuditableBehavior is a propel behavior to track and record changes in your propel models.
MIT
behavior propel blameable auditable