난 당신이 무슨 말을하는지 오해 아니에요 경우, 당신이 원하는 필터, 예를 들면, 저장하기 전에 객체에 'created'또는 'modified'값을 자동으로 추가하십시오.
내가 어떻게하는지. 내 extensions/data/Model.php
<?php
namespace app\extensions\data;
use lithium\security\Password;
class Model extends \lithium\data\Model {
public static function __init() {
parent::__init();
// {{{ Filters
static::applyFilter('save', function($self, $params, $chain) {
$date = date('Y-m-d H:i:s', time());
$schema = $self::schema();
//do these things only if they don't exist (i.e. on creation of object)
if (!$params['entity']->exists()) {
//hash password
if (isset($params['data']['password'])) {
$params['data']['password'] = Password::hash($params['data']['password']);
}
//if 'created' doesn't already exist and is defined in the schema...
if (empty($params['date']['created']) && array_key_exists('created', $schema)) {
$params['data']['created'] = $date;
}
}
if (array_key_exists('modified', $schema)) {
$params['data']['modified'] = $date;
}
return $chain->next($self, $params, $chain);
});
// }}}
}
}
?>
에서
는 좀 비밀번호뿐만 아니라이 해시 있습니다. 기능에 영향을 미치지 않고 제거 할 수 있습니다.