Skip to content
This repository has been archived by the owner on Aug 14, 2019. It is now read-only.

fizyk/fzBlameablePlugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

fzBlameable

While it is possible to use clean Doctrine extension blameable, it's possible that you'll forget to add customized listener to every table that needs Blameable behaviour. Goal of this plugin is to provide customized Blameable for symfony with back relation alias. Apart from that change it's almost identical to the diem's modification to Blameable plugin.

Original behaviour could be found there: doctrine-project.org before the change in doctrine-project.org website. Modification applied to listener could be found here.

Instalation:

To install plugin from symfony plugin repository run:

./symfony plugin:install fzBlameablePlugin

To install plugin from package, copy it to your project root's directory and run:

./symfony plugin:install fzBlameablePlugin-1.1.0.tgz

After installing, you have to run:

Usage:

To use this behaviour simply add fzBlameable to your model:

MyModel:
  actAs:
    fzBlameable:

And then run:

./symfony doctrine:generate-migrations-diff
./symfony doctrine:migrate
./symfony doctrine:build --all-classes

After that you'll have two fields created_by and updated_by added to your model, and two relations between your model, and sfGuardUser. By default, both created and updated fields and relations will be enabled allowing null values.

These are default settings for columns fzBlameable, you don't have to write them unless you want to change them!

MyModel:
  actAs:
    fzBlameable:
      columns:
        created:
          name: created_by
          alias: null
          type: integer
          length: 8
          disabled: false
          options:
            notnull: false
        updated:
          #same as for created here

Default values for created_by and updated_by are suited for sfDoctrineGuard 5.x

You can also modify relations:

MyModel:
  actAs:
    fzBlameable:
      relations:
        created:
          disabled: false
          name: CreatedBy
          foreign: id
          foreignAlias: false
        updated:
          #same as for created here

###DQL Usage###

To use this relations in dql, you have as in original behaviour, CreatedBy relation in the model with behaviour. Additionally fzBlameable adds CreatedMyModels relation alias to the sfGuardUser, which eases creation of complex dql queries.

The CreatedMyModels is default name for relation alias on sfGuardUser model. To set own name, please modify foreignAlias setting for each relation

Thanks

Thanks to:

*Colin DeCarlo, author of the original behaviour, *Sean Villani, for information about modifying Blameable for sfGuardUser

About

Provides out of the box blameable behaviour for symfony/doctrine with few adjustment

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages