sfDoctrineActAsSignablePlugin - 1.2.0

sfDoctrineActAsSignablePlugin provides Signable behavior to your models ("created_by" and "updated_by"columns defining user who created/updated a record)

You are currently browsing
the website for symfony 1

Visit the Symfony2 website

« Back to the Plugins Home


Forgot your password?
Create an account



advanced search
Information Readme Releases Changelog Contribute
Show source


The sfDoctrineActAsSignablePlugin plugin automates the handling of created_by and updated_by columns. Each time a Signable object is inserted or updated, those columns are automatically updated accordingly to the user who saved the changes.


Install the plugin via the subversion repository by executing the following command from the project root directory:

$ svn co http://svn.symfony-project.com/plugins/sfDoctrineActAsSignablePlugin/trunk plugins/sfDoctrineActAsSignablePlugin

or by using the default symfony plugin install command:

$ ./symfony plugin:install sfDoctrineActAsSignablePlugin


Add the desired columns to your schema.yml for the tables you want to be signed. You can use a string or an int type, the behavior will automatically detect the type and store the corresponding information depending on this type (for a string the username is stored, and for an integer it's the user's ID).

# You can either set the type of a column to a string (will store the username) or an integer (will store the user ID)

      name: created_by
      type: integer
        notnull: true
        default: 1
      name: updated_by
      type: string

Also you may use global behavior in your doctrine schema (default field value is integer):

actAs: [Timestampable, Signable]


There is no required dependency, although :


The plugin is provided with behavior relations for sfDoctrineGuardPlugin. For created and updated options which are defined as active (not disabled) and integer type, creator and updator relations are available, respectively. This means, that if you attach Signable behavior (defined as mentioned above) to any of your model, you can directly access sfGuardUser class objects. For example, the Article model is defined as follows:

    Signable: ~

you can access the user who created/updated the Article (integer option is the default in the Signable):

echo $article->getCreator();
echo $article->getUpdator()->customMethod();

Example use cases

Here are some example cases when you may find this plugin useful:

string user reference

The project includes a blog or a forum system. Each blog/forum post page needs to display the user who posted it (or modified it last time). The symfony forum screenshot last column shows LAST POST, user name is highlighted in red (Singable behavior) and the timestamp is highlighted in green (Timestampable behavior):

symfony forum

integer user reference

The more advanced technique is to use an integer created_by/updated_by column (the default) to store the user's ID (need to have appropriate user table, e.g. sfDoctrineGuardPlugin). In this case you may use relations and fetch User object at runtime (which is very difficult if you store user name as a string).

This option is very useful when developing a CRM or ERP system where data modification is important (could be combined with data versioning).

Thanks to

Thomas Boerger, Michael Klein, Kary Leong, geoffrey: The snippet this plugin is based on.