Skip to content
forked from mongator/behaviors

These are the official behaviors of Mongator

License

Notifications You must be signed in to change notification settings

tepio/behaviors

 
 

Repository files navigation

Mongator Behaviors Build Status

These are the official behaviors of Mongator.

  • Timestampable: Saves the creation and/or update date in the documents.
  • Ipable: Saves the IP from where documents are created and/or saved.
  • Sluggable: Saves the slug of a field in the documents.
  • Archivable: Saves a document copy from one collection to another.
  • Tokenizable: Generates a token on creation.
  • Hasable: Generates a hash for given fields/rels/embs from the given document, on update and/or creation.
  • AutoIncrementable: Auto incrementable field like AUTO_INCREMENT in MySQL
  • Identifiable: Automatically saves an identifier in the document.

Requirements

  • PHP 5.3.x;
  • mongator/mongator

Installation

The recommended way of installing Mongator Behaviors is through composer. You can see package information on Packagist.

{
    "require": {
        "mongator/behaviors": "1.0.*"
    }
}

Examples

On your document definition just add a new array named behaviors, just like this:

'Model\MyCollecion' => array(
    'fields' => array(
        'title' => 'string',
    ),
    'behaviors' => array(
        array('class' => 'Mongator\Behavior\Tokenizable'),
        array('class' => 'Mongator\Behavior\Archivable'),
    ),
),

Tests

Tests are in the tests folder. To run them, you need PHPUnit. Example:

$ phpunit --configuration phpunit.xml.dist

License

MIT, see LICENSE

About

These are the official behaviors of Mongator

Resources

License

Stars

Watchers

Forks

Packages

No packages published