This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use Stack Overflow.

Accessible behavior plugin - developers wanted

Requests for new symfony features.

Accessible behavior plugin - developers wanted

by tkoomzaaskz » Mon Nov 01, 2010 6:16 pm

I have an idea of a highly complex Doctrine behavior, Accessible. It's gonna be a mixture of two existing behaviors: Versionable and Signable and some more: it should keep entire history of all data changes and user actions. It should give you the possibility to track all changes done on an Accessible object and to track all activities of a given user (like last 100 actions).

Versionable gives you the possibility to store all changes in a new table, xxx_version whenever the record is changed.
Signable saves who created/updated a record.

New things to add: one additional table for entire system, let's call it access. It consists of 4 columns:
* record_id (id of the record),
* table (name of the record table),
* created_at (when the action took place),
* user_id (foreign key to sfDoctrineGuard)

This table will enable to list actions of a given user, no matter which table records were modified. Let's suppose our system has 150 different tables that are marked as versionable and signable (updated_at and updated_by columns are used - all data changes are stored in the database). Now, we want to list last 100 actions of a given user... With no auxiliary table, the only way is to retrieve all changes from all 150 tables, then merge them by datetime, choose last 100 and here it comes. With an auxiliary table, it's a lot easier.

So far, I have done a very dirty solution for my existing project: I have created manually an Access table (with schema.yml), copied entire Versionable into project lib folder, renamed those files to Accessible and added/modified postInsert, postUpdate and postDelete methods of the listener class. It works, but no way, it's not a nice solution and I can't distribute this feature as a plugin (too ugly to publish). And I think it could be found useful by many developers who want to track all changes in their system along with user information.

I have been studying Versionable, but I found it more complicated than I expected. Just some high-level Doctrine skills are needed to help me with this behavior. What I find difficult is dynamic creating tables (such as xxx_version) - need to add the access table that is the same for all accessible models. Overriding postInsert, postUpdate and postDelete is obvious.

Please contact me if anyone wants to contribute.
User avatar
tkoomzaaskz
Faithful Member
 
Posts: 239
Joined: Fri Feb 01, 2008 1:32 pm
Location: Poland