Developers

License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Release 1.1.0 - 03/10/2010

Release 1.0.0 - 12/07/2009

sfDoctrineActAsSignablePlugin

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.

Instalation

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

Usage

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)
actAs:
Signable:
created:
name: created_by
type: integer
options:
notnull: true
default: 1
updated:
name: updated_by
type: string

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

actAs: [Timestampable, Signable]

Dependencies

Relations

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:

Article:
actAs:
Signable: ~

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

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):

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).