Skip to content

Commit

Permalink
Readme tweaks. Misc cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
beporter committed Jul 22, 2015
1 parent a3a865e commit 42facde
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 1,471 deletions.
10 changes: 2 additions & 8 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
CakePHP 3

/vendor/*
/config/app.php
/tmp/*
/logs/*

CakePHP 2

/app/tmp/*
/app/Config/core.php
/app/Config/database.php
/vendors/*
# Ignore the composer lock file-- it should never be included in a distributed package.
/composer.lock
30 changes: 21 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# CreatorModifier
# CakePHP 3 CreatorModifier plugin

[![Latest Version](https://img.shields.io/github/release/loadsys/CakePHP-CreatorModifier.svg?style=flat-square)](https://github.com/loadsys/CakePHP-CreatorModifier/releases)
[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Build Status](https://travis-ci.org/loadsys/CakePHP-CreatorModifier.svg?branch=master&style=flat-square)](https://travis-ci.org/loadsys/CakePHP-SocialLinks)
[![Coverage Status](https://coveralls.io/repos/loadsys/CakePHP-CreatorModifier/badge.svg)](https://coveralls.io/r/loadsys/CakePHP-CreatorModifier)
[![Total Downloads](https://img.shields.io/packagist/dt/loadsys/cakephp-creatormodifier.svg?style=flat-square)](https://packagist.org/packages/loadsys/cakephp-creatormodifier)

Sets a `creator_id` and `modifier_id` using the logged in User.id field.
Sets a `creator_id` and `modifier_id` on records during save using the logged in User.id field. Operates almost identically to the core's [Timestamp behavior](http://book.cakephp.org/3.0/en/orm/behaviors/timestamp.html).


## Requirements

* PHP 5.4.16+
* CakePHP 3.0+


## Installation

### Composer
Expand All @@ -21,9 +23,10 @@ Sets a `creator_id` and `modifier_id` using the logged in User.id field.
$ composer require loadsys/loadsys/cakephp-creatormodifier:~1.0
````

## Usage ##

* Add this plugin for use in an Table, by adding this line to your Table's `initialize` method.
## Usage

* Add this plugin for use in an Table, by adding this line to your Table's `initialize()` method.

````php
$this->addBehavior('CreatorModifier.CreatorModifier');
Expand All @@ -35,14 +38,22 @@ $this->addBehavior('CreatorModifier.CreatorModifier');
$this->addBehavior('CreatorModifier.CreatorModifier', [
'events' => [
'Model.beforeSave' => [
'user_who_created_me_id' => 'new', // field of the User.id who created, only change on beforeSave when is a new Entity.
'user_who_modified_me_id' => 'always' // field of the User.id who modified, always change on beforeSave.
// Field storing the User.id who created the record,
// only triggers on beforeSave when the Entity is new.
'user_who_created_me_id' => 'new',

// Field storing the User.id who modified the record,
// always triggers on beforeSave.
'user_who_modified_me_id' => 'always'
]
],
'sessionUserIdKey' => 'Auth.User.id', // The key to read from `\Cake\Network\Request->session()->read('Auth.User.id');` for the User.id value to set.
// The key to read from `\Cake\Network\Request->session()->read();`
// to obtain the User.id value to set during saves.
'sessionUserIdKey' => 'Auth.User.id',
]);
````


## Contributing

### Reporting Issues
Expand All @@ -53,11 +64,12 @@ Please use [GitHub Isuses](https://github.com/loadsys/CakePHP-CreatorModifier/is

When developing this plugin, please fork and issue a PR for any new development.

## License ##

## License

[MIT](https://github.com/loadsys/CakePHP-CreatorModifier/blob/master/LICENSE.md)


## Copyright ##
## Copyright

[Loadsys Web Strategies](http://www.loadsys.com) 2015
7 changes: 5 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"name": "loadsys/cakephp-creatormodifier",
"description": "CakePHP 3.x Plugin To Add Creator and Modifier Automagic fields.",
"description": "CakePHP 3.x Plugin to set Creator and Modifier automagic fields during save.",
"type": "cakephp-plugin",
"keywords": [
"cakephp",
"plugin",
"behavior"
"behavior",
"user",
"creator",
"modifier"
],
"homepage": "https://github.com/loadsys/CakePHP-CreatorModifier",
"license": "MIT",
Expand Down
Loading

0 comments on commit 42facde

Please sign in to comment.