Coder Social home page Coder Social logo

fr0z3nfyr / revisionable Goto Github PK

View Code? Open in Web Editor NEW

This project forked from analogrithems/revisionable

0.0 1.0 0.0 100 KB

CakePHP Revisionable Plugin

Home Page: http://www.analogrithems.com/rant/2011/12/05/revisionable-behavior-in-cakephp/

PHP 100.00%

revisionable's Introduction

Table of Contents

CakePHP Simple Revisionable Behavior

This is a simple small plugin that adds a revisionable behavior to any of your models

It does this by grabbing a copy of your row right before you save it and saving a serialized copy of it in the serialize table

This plugin is pretty easy to use

Setup

1) First you need to add the table to your project use the following to generate that cake schema create Revisionable.revision

2) add the behavior to your model like so

var $actAs = array('Revisionable.Revisionable');

3) I've discovered that cakephp has some bugs in it's schema create script that doesn't account for longblob, so make sure that after you run the cake schema create Revisionable.revision you go change the data type for the data column to longblob otherwise you may not get your revision saved properly.

Some Configure options

If you already have a table named revisions in your project and need to call the it something else then make a new table/model in your project that has the same schema as this plugin and pass that model name to the actAs setup like so

var $actAs('Revisionable.Revisionable'=>array('revisionableModel'=>$newModelName));

To Do

So far aside from creating a revision everytime the data changes the only other feature of this plugin is the listRevisions function. It works like this

$revisions = $this->Model->listRevisions($this->Model->id);

print_r($revisions); array( '2011-12-05 01:01:01'=>array( 'Pages' => array( 'id'=> '4edd8cc3-a628-490b-8cbf-6435ac1005e9', 'name'=> 'foobar', 'body'=> '....' ) ) );

Need to create some more functions that add to this, like perhaps a diff viewer

Patches are warmly welcome.

-Analog

revisionable's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.