Created
December 1, 2011 20:38
-
-
Save fitzagard/1419668 to your computer and use it in GitHub Desktop.
Li3 Filter Example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Base extends \lithium\data\Model { | |
public $validates = array(); | |
public static function __init(array $options = array()){ | |
parent::__init($options); | |
/** | |
* Add created date to every document created | |
*/ | |
static::applyFilter('create', function($self, $params, $chain){ | |
$params['data']['created_date'] = new MongoDate(); | |
return $chain->next($self, $params, $chain); | |
}); | |
/** | |
* Add modified date to every document created | |
*/ | |
static::applyFilter('save', function($self, $params, $chain){ | |
$params['data']['modified_date'] = new MongoDate(); | |
return $chain->next($self, $params, $chain); | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment