本文整理匯總了PHP中sfRequest::getPostParameters方法的典型用法代碼示例。如果您正苦於以下問題:PHP sfRequest::getPostParameters方法的具體用法?PHP sfRequest::getPostParameters怎麽用?PHP sfRequest::getPostParameters使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sfRequest
的用法示例。
在下文中一共展示了sfRequest::getPostParameters方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: executeCitiCashBackApplication
/**
* Приём анкеты Сити банка
*/
public function executeCitiCashBackApplication(sfRequest $request)
{
$form = new CitiBankApplicationForm();
$form->bind($request->getPostParameters());
if ($form->isValid()) {
$this->_sendEmail($form->getValues());
return $this->renderJsonSuccess('Анкета успешно отправлена');
}
$errors = $form->getErrorSchema()->getErrors();
$errorMessages = array();
//TODO: refactor: все сообщения русским языком должны создаваться на клиенте,
//сервер должен слать только код поля (например, "email") и сообщение валидатора
$humanFieldNames = array("email" => "Email", "birthday" => "Дата рождения", "name" => "Имя", "patronymic" => "Отчество", "surname" => "Фамилия", "mobile_phone" => "Мобильный телефон");
foreach ($errors as $fieldName => $error) {
$errorMessages[] = sprintf("%s", $humanFieldNames[$fieldName]);
}
return $this->renderJsonError("Пожалуйста, исправьте заполнение полей: \n" . implode(', ', $errorMessages));
}
示例2: executeSave
/**
* Сохранить профиль пользователя
*/
public function executeSave(sfRequest $request)
{
$user = $this->getUser()->getUserRecord();
$this->form = new UserProfileForm($user);
$this->getResponse()->setHttpHeader('Content-Type', 'application/json; charset=utf-8');
$postParameters = $request->getPostParameters();
$formParameters = array();
// default fields
$fields = array('mailIntegration' => 'user_service_mail', 'nickname' => 'name');
// грязный хак для (от) Рамблёра
if (strpos($_SERVER['HTTP_HOST'], 'rambler') === false) {
$fields = array_merge(array('login' => 'user_login', 'mail' => 'user_mail', 'pass' => 'password', 'newpass' => 'password_new', 'getNotify' => 'notify'), $fields);
}
foreach ($fields as $parameter => $field) {
if (array_key_exists($parameter, $postParameters)) {
$formParameters[$field] = $postParameters[$parameter];
}
}
$this->form->bind($formParameters, array());
if ($this->form->isValid()) {
$this->form->save();
return $this->renderText(json_encode(array('result' => array('text' => 'Данные успешно сохранены'))));
}
$err = $this->form->getErrorSchema();
$string = '';
foreach ($err as $errors) {
if ($errors instanceof sfValidatorErrorSchema) {
foreach ($errors as $code => $message) {
$string .= $message->getMessage() . "<br /><br />\n";
}
} elseif ($errors instanceof sfValidatorError) {
$string .= $errors->getMessage() . "<br /><br />\n";
} else {
$string .= $errors . "<br /><br />\n";
}
}
return $this->renderText(json_encode(array('error' => array('text' => $string))));
}
示例3: executeLogin
/**
* Авторизация пользователя
*/
public function executeLogin(sfRequest $request)
{
$this->setLayout("layout");
$user = $this->getUser();
if ($user->isAuthenticated()) {
return $this->redirect('@homepage');
}
// Запрос на авторизацию
if ($request->isMethod('post')) {
$this->form = new myAuthForm();
$params = $request->getPostParameters();
$this->form->bind($params['auth']);
if ($this->form->isValid()) {
$values = $this->form->getValues();
$remember = array_key_exists('remember', $values) ? $values['remember'] : false;
$user->signIn($this->form->getUser(), $remember);
return $this->redirect('@homepage');
}
// Форвард из других контроллеров
} else {
$this->form = new myAuthForm();
}
return sfView::SUCCESS;
}
示例4: executeLogin
/**
* Авторизация пользователя / сообщение о неавторизованности
*/
public function executeLogin(sfRequest $request)
{
$this->setLayout("layout");
$user = $this->getUser();
if (!$user->isAuthenticated()) {
if ($request->isMethod('post')) {
$form = new myAuthForm();
$form->bind($request->getPostParameters());
if ($form->isValid()) {
$userRecord = $form->getUser();
} else {
return $this->raiseError($form->getErrorSchema());
}
} else {
return $this->raiseError('Authentification required');
}
$user->signIn($userRecord);
}
if (!$this->checkSubscription()) {
$user->signOut();
return $this->raiseError('Payment required', 402);
}
return sfView::SUCCESS;
}