本文整理匯總了PHP中input::instance方法的典型用法代碼示例。如果您正苦於以下問題:PHP input::instance方法的具體用法?PHP input::instance怎麽用?PHP input::instance使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類input
的用法示例。
在下文中一共展示了input::instance方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: preValidate
public function preValidate(Doctrine_Event $event)
{
$user = input::instance()->post('user', array());
$record =& $event->getInvoker();
$errorStack = $this->getErrorStack();
$validation = Bluebox_Controller::$validation;
if (!isset($user['username']) and isset($user['email_address'])) {
$record['username'] = $user['email_address'];
}
if (!empty($user['create_password'])) {
$record['password'] = $user['create_password'];
}
if (Router::$method == 'create') {
if (empty($user['create_password'])) {
$validation->add_error('user[create_password]', 'Please provide a password');
$errorStack->add('password', 'notblank');
}
if (empty($user['confirm_password'])) {
$validation->add_error('user[confirm_password]', 'Please confirm your password');
$errorStack->add('password', 'noconfirm');
}
if ($user['confirm_password'] !== $user['create_password']) {
$validation->add_error('user[confirm_password]', 'Password does not match');
$errorStack->add('password', 'nomatch');
}
} else {
if (!empty($user['create_password'])) {
if (empty($user['confirm_password'])) {
$validation->add_error('user[confirm_password]', 'Please confirm your password');
$errorStack->add('password', 'noconfirm');
}
if ($user['confirm_password'] !== $user['create_password']) {
$validation->add_error('user[confirm_password]', 'Password does not match');
$errorStack->add('password', 'nomatch');
}
}
}
$enforce = Kohana::config('core.pwd_complexity');
if (empty($enforce) || empty($user['create_password'])) {
return TRUE;
}
// at least one digit
if (!preg_match('/[0-9]{1,}/', $user['create_password'])) {
$validation->add_error('user[create_password]', 'Password must contain digits and letters');
$errorStack->add('password', 'nocomplexity');
}
// at least one character
if (!preg_match('/[A-Za-z]{1,}/', $user['create_password'])) {
$validation->add_error('user[create_password]', 'Password must contain digits and letters');
$errorStack->add('password', 'nocomplexity');
}
}
示例2: remove_from_query_string
public static function remove_from_query_string($param)
{
$parameters = input::instance()->get();
unset($parameters[$param]);
return url::base() . url::current() . '?' . http_build_query($parameters);
}