本文整理汇总了PHP中Psr\Http\Message\ServerRequestInterface::isPost方法的典型用法代码示例。如果您正苦于以下问题:PHP ServerRequestInterface::isPost方法的具体用法?PHP ServerRequestInterface::isPost怎么用?PHP ServerRequestInterface::isPost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Psr\Http\Message\ServerRequestInterface
的用法示例。
在下文中一共展示了ServerRequestInterface::isPost方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: loginAction
public function loginAction(Request $request, Response $response, $args)
{
$hash = new Hash();
if ($request->isPost()) {
$data = $request->getParsedBody();
try {
$User = $this->em->getRepository('App\\Model\\Users')->findOneBy(['username' => $data['username']]);
} catch (\Exception $e) {
echo $e->getMessage();
die;
}
if (is_null($User)) {
$this->flash->addMessage('error', 'NAME FAIL');
} else {
$pass = $hash->create($data['password'], SALT);
if ($User->getPassword() == $pass) {
$this->flash->addMessage('success', "SUCCESS !");
$_SESSION['user'] = ['username' => $User->getUsername(), 'email' => $User->getEmail(), 'role' => $User->getRole()];
} else {
$this->flash->addMessage('error', "PASS FAIL !!!");
}
}
return $response->withStatus(301)->withHeader('Location', '/');
} else {
$flash_success = $this->flash->getMessage('success');
$flash_error = $this->flash->getMessage('error');
$this->view->render($response, 'user/login.html', ['flash_success' => $flash_success, 'flash_error' => $flash_error]);
return $response;
}
}
示例2: checkToken
private function checkToken(ServerRequestInterface $request)
{
$params = $request->getQueryParams();
if ($request->isPost()) {
$params = $request->getParsedBody();
}
$token = $params['token'] ?: '';
return false;
}
示例3: addPostAction
public function addPostAction(Request $request, Response $response)
{
if ($request->isPost()) {
$data = $request->getParsedBody();
$title = $data['post_title'];
$slug = trim($title);
$slug = str_replace(' ', '-', $slug);
$alias = $data['post_alias'];
$content = $data['post_data'];
$id = string($data['cat']);
$post = new Posts();
$post->setAlias($alias);
$post->setCategory($id);
$post->setPublished(true);
$post->setSlug($slug);
$post->setContent($content);
$this->em->persist($post);
$this->em->flush();
}
$this->view->render($response, 'admin/post/newpost.html', ['post' => $post]);
return $response;
}
示例4: edit
public function edit(Request $request, Response $response, $args)
{
$data_form = $this->getIndicadorService()->getById($args['id']);
$form = $this->getIndicadorForm();
$form->setData($data_form);
if ($request->isPost()) {
$data_form = $request->getParsedBody();
foreach ($data_form['fieldset_periodo'] as $key => $item) {
$date = substr($item, -4) . '-' . substr($item, 0, 2) . '-01';
$data_form['fieldset_periodo'][$key] = new \DateTime($date);
}
$form->setData($data_form);
if ($form->isValid()) {
$this->getIndicadorService()->save($data_form, $args['id']);
return $response->withRedirect($this->router->pathFor('indicador'));
} else {
$form->setData($request->getParsedBody());
}
}
$this->view->render($response, 'indicador/edit.twig', array('form' => $form));
return $response;
}