dev-master
9999999-devA revision-tracking plugin for CakePHP 3. Developed at CakeFest2015.
WTFPL
The Requires
by isaac
by btx
by tiinusen
A revision-tracking plugin for CakePHP 3. Developed at CakeFest2015.
CakePHP Revisions plugin (CakeFest 2015), (*1)
A Plugin for CakePHP 3.x that allows you to track Revisions to Tables (at the entity level) in your Application, (*2)
[Using Composer], (*3)
Add the plugin to your project's composer.json
- something like this:, (*4)
{ "require": { "cwbit/cakephp-revisions": "dev-master" } }
Because this plugin has the type cakephp-plugin
set in it's own composer.json
composer knows to install it inside your /plugins
directory (rather than in the usual 'Vendor' folder). It is recommended that you add /plugins/Revisions
to your cake app's .gitignore file. (Why? read this.), (*5)
[Manual], (*6)
plugins
Revisions
[GIT Submodule], (*7)
In your app
directory type:, (*8)
git submodule add -b master git://github.com/cwbit/cakephp-revisions.git plugins/Revisions git submodule init git submodule update
[GIT Clone], (*9)
In your plugins
directory type:, (*10)
git clone -b master git://github.com/cwbit/cakephp-revisions.git Revisions
In 3.0 you need to enable the plugin your config/bootstrap.php
file:, (*11)
Plugin::load('Revisions');
If you are already using Plugin::loadAll();
, then this is not necessary., (*12)
Add the Behavior to any Table you want to track versions of, (*13)
The Basic Implementation will fire any time any field on the entity is modified., (*14)
public function initialize(){ parent::initialize(); $this->addBehavior('Revisions.Revisions'); }
You can also explicitly tell the Plugin to only trigger version control if specific field(s) have been modified., (*15)
public function initialize(){ parent::initialize(); $this->addBehavior('Revisions.Revisions', [ 'watch' => [ 'name', # trigger if, 'foo', # and only if, 'bar' # any of these fields are changed ], ]); }
You can also explicitly tell the Plugin to ignore modifications to certain fields. The version control will only trigger if at least one other (non-ignored) field has been changed., (*16)
public function initialize(){ parent::initialize(); $this->addBehavior('Revisions.Revisions', [ 'ignore' => [ 'bigBlob', # only trigger if something 'created', # OTHER than these fields 'modified', # was changed ], ]); }
The Plugin also comes with the ability to view all revisions and restore to any given point in time., (*17)
To enable this functionality, add and customize the following line in any view, (*18)
= $this->Element('Revisions.Revisions/index', [ 'id' => $entity->id, # replace with actual entity variable 'model' => 'examples', # replace with actual model 'limit' => 10, # optional ]);?>
A revision-tracking plugin for CakePHP 3. Developed at CakeFest2015.
WTFPL