本文整理汇总了PHP中app\models\Users::applyFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Users::applyFilter方法的具体用法?PHP Users::applyFilter怎么用?PHP Users::applyFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Users
的用法示例。
在下文中一共展示了Users::applyFilter方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
<?php
use app\models\Users;
use lithium\security\Password;
Users::applyFilter('save', function ($self, $params, $chain) {
if ($params['data']) {
$params['entity']->set($params['data']);
$params['data'] = array();
}
if (!$params['entity']->exists()) {
$params['entity']->password = Password::hash($params['entity']->password);
}
return $chain->next($self, $params, $chain);
});
示例2: function
return false;
}
});
Validator::add('uniqueUsername', function ($value, $rule, $options) {
$conflicts = Users::count(array('username' => $value));
if ($conflicts) {
return false;
}
return true;
});
Validator::add('uniqueEmail', function ($value, $rule, $options) {
$conflicts = Users::count(array('email' => $value));
if ($conflicts) {
return false;
}
return true;
});
Users::applyFilter('save', function ($self, $params, $chain) {
if ($params['data']) {
$params['entity']->set($params['data']);
$params['data'] = array();
}
if (!$params['entity']->exists()) {
$params['entity']->password = String::hash($params['entity']->password);
$params['entity']->password2 = String::hash($params['entity']->password2);
$params['entity']->created = new \MongoDate();
$params['entity']->updated = new \MongoDate();
$params['entity']->ip = $_SERVER['REMOTE_ADDR'];
}
return $chain->next($self, $params, $chain);
});
示例3: function
Validator::add('uniqueWalletID', function ($value, $rule, $options) {
$conflicts = Users::count(array('walletid' => $value));
if ($conflicts) {
return false;
}
return true;
});
Validator::add('uniqueEmail', function ($value, $rule, $options) {
$conflicts = Users::count(array('email' => $value));
if ($conflicts) {
return false;
}
return true;
});
Validator::add('uniqueUsername', function ($value, $rule, $options) {
$conflicts = Users::count(array('username' => $value));
if ($conflicts) {
return false;
}
return true;
});
Users::applyFilter('save', function ($self, $params, $chain) {
if ($params['data']) {
$params['entity']->set($params['data']);
$params['data'] = array();
}
if (!$params['entity']->exists()) {
$params['entity']->created = new \MongoDate();
}
return $chain->next($self, $params, $chain);
});
示例4: function
<?php
use app\models\Users;
use lithium\security\Password;
Users::applyFilter('save', function ($self, $params, $chain) {
if ($params['data']) {
$params['entity']->set($params['data']);
$params['data'] = array();
}
$record = $params['entity'];
//password is provided, we need to hash it
if (!empty($record->password)) {
$record->password = lithium\util\String::hash($record->password);
}
return $chain->next($self, $params, $chain);
});
示例5: function
}
Validator::add('passwordVerification', function ($value, $rule, $options) {
if (!isset($options['values']['password2']) || $value == $options['values']['password2']) {
return true;
}
return false;
});
Validator::add('uniqueUsername', function ($value, $rule, $options) {
$conflicts = Users::count(array('username' => $value));
if ($conflicts) {
return false;
}
return true;
});
Users::applyFilter('save', function ($self, $params, $chain) {
$entity = $params['entity'];
$data = $params['data'];
if ($data) {
$entity->set($data);
if (isset($data['password']) && $data['password'] && isset($data['password2']) && $data['password2']) {
$entity->password = \lithium\util\String::hash($data['password']);
$entity->password2 = \lithium\util\String::hash($data['password2']);
}
}
if (!$entity->id) {
$entity->created = new \MongoDate();
}
$entity->updated = new \MongoDate();
$params['entity'] = $entity;
return $chain->next($self, $params, $chain);
});