当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::isPost方法代码示例

本文整理汇总了PHP中Slim\Http\Request::isPost方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::isPost方法的具体用法?PHP Request::isPost怎么用?PHP Request::isPost使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Slim\Http\Request的用法示例。


在下文中一共展示了Request::isPost方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __invoke

 public function __invoke(Request $req, Response $res)
 {
     $school = $req->getAttribute('school');
     if ($req->isPost()) {
         $this->appFormInputFilter->setData(array_merge($req->getParams(), ['school_id' => $school->id, 'submitted_by' => $this->authService->getIdentity()->mail]));
         $isValid = $this->appFormInputFilter->isValid();
         if ($isValid) {
             $data = $this->appFormInputFilter->getValues();
             $appForm = $this->appFormService->submit($data);
             $_SESSION['applicationForm']['appForm'] = $appForm;
             $res = $res->withRedirect($this->successUrl);
             return $res;
         }
         $this->view['form'] = ['is_valid' => $isValid, 'values' => $this->appFormInputFilter->getValues(), 'raw_values' => $this->appFormInputFilter->getRawValues(), 'messages' => $this->appFormInputFilter->getMessages()];
     }
     $loadForm = (bool) $req->getParam('load', false);
     $this->view['choose'] = !$loadForm && !$req->isPost();
     if (!$req->isPost() && $loadForm) {
         if (null !== ($appForm = $this->appFormService->findSchoolApplicationForm($school->id))) {
             $this->view['form'] = ['values' => $appForm];
         }
     }
     $labs = $this->labService->getLabsBySchoolId($school->id);
     $res = $this->view->render($res, 'application_form/form.twig', ['lab_choices' => array_map(function ($lab) {
         return ['value' => $lab['id'], 'label' => $lab['name']];
     }, $labs), 'type_choices' => array_map(function ($category) {
         return ['value' => $category['id'], 'label' => $category['name']];
     }, $this->assetsService->getAllItemCategories())]);
     return $res;
 }
开发者ID:kanellov,项目名称:gredu_labs,代码行数:30,代码来源:ApplicationForm.php

示例2: cleanupOldFiles

 public function cleanupOldFiles()
 {
     $_SESSION['DB_DONE'] = true;
     $cleanupList = array_merge($this->pluginFinder->getDummyPlugins(), $this->filesFinder->getCleanupFiles());
     $this->cleanupMedia();
     if (count($cleanupList) == 0) {
         $_SESSION['CLEANUP_DONE'] = true;
         $this->response->redirect($this->app->urlFor('done'));
     }
     if ($this->request->isPost()) {
         $result = [];
         foreach ($cleanupList as $path) {
             $result = array_merge($result, Utils::cleanPath($path));
         }
         if (count($result) == 0) {
             $_SESSION['CLEANUP_DONE'] = true;
             $this->response->redirect($this->app->urlFor('done'));
         } else {
             $result = array_map(function ($path) {
                 return substr($path, strlen(SW_PATH) + 1);
             }, $result);
             $this->app->render('cleanup.php', ['cleanupList' => $result, 'error' => true]);
         }
     } else {
         $cleanupList = array_map(function ($path) {
             return substr($path, strlen(SW_PATH) + 1);
         }, $cleanupList);
         $this->app->render('cleanup.php', ['cleanupList' => $cleanupList, 'error' => false]);
     }
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:30,代码来源:CleanupController.php

示例3: login

 public function login(Request $request, Response $response, array $args)
 {
     $this->logger->info("Login page action dispatched");
     $username = null;
     $error = null;
     $urlRedirect = $request->getUri()->getBaseUrl() . $this->router->pathFor('homepage');
     //        if ($request->getAttribute('r') && $request->getAttribute('r') != '/logout' && $request->getAttribute('r') != '/login') {
     //            $_SESSION['urlRedirect'] = $request->getAttribute('r');
     //        }
     if (isset($_SESSION['urlRedirect'])) {
         $urlRedirect = $_SESSION['urlRedirect'];
         unset($_SESSION['urlRedirect']);
     }
     if ($request->isPost()) {
         $username = $request->getParam('username');
         $password = $request->getParam('password');
         $result = $this->authenticator->authenticate($username, $password);
         if ($result->isValid()) {
             //$error = $this->authenticator->getIdentity();
             return $response->withRedirect($urlRedirect);
         } else {
             $messages = $result->getMessages();
             $error = (string) $messages[0];
             //$this->flash->addMessage('flash', $error);
         }
     }
     $this->view->render($response, 'login.twig', ['username' => $username, 'error' => $error]);
     return $response;
 }
开发者ID:neilmillard,项目名称:fxtrader,代码行数:29,代码来源:LoginAction.php

示例4: __invoke

 public function __invoke(Request $req, Response $res)
 {
     $school = $req->getAttribute('school', false);
     if (!$school) {
         return $res->withStatus(403, 'No school');
     }
     $teacherId = $req->getParam('teacher_id');
     $teacher = $this->staffService->getTeacherById($teacherId);
     if ($teacher['school_id'] !== $school->id) {
         return $res->withStatus(403, 'No school');
     }
     if ($req->isPost()) {
         $inputFilter = $this->inputFilter;
         $result = $inputFilter($req->getParams());
         if (!$result['is_valid']) {
             $res = $res->withStatus(422);
             $res = $res->withJson($result);
             return $res;
         }
         $this->service->saveAnswers($teacherId, $result['values']);
     }
     $data = $this->service->getAnswers($teacherId);
     $res = $res->withJson($data);
     return $res;
 }
开发者ID:eellak,项目名称:gredu_labs,代码行数:25,代码来源:SurveyForm.php

示例5: dispatch

 public function dispatch(Request $request, Response $response, $args)
 {
     $speakers = $this->eventManager->getSpeakers();
     $venues = $this->eventService->getVenues();
     $supporters = $this->eventManager->getSupporters();
     $eventInfo = ['title' => '', 'description' => ''];
     if ($request->getParam('meetup_id')) {
         $event = $this->eventService->getEventById((int) $request->getParam('meetup_id'));
         if (!empty($event)) {
             $eventInfo['title'] = $event['subject'];
             $eventInfo['description'] = $event['description'];
             $eventInfo['venue_id'] = $event['venue_id'];
             $date = \DateTime::createFromFormat('F jS Y', $event['date']);
             $eventInfo['date'] = $date->format("d/m/Y");
         }
     }
     $errors = $this->flash->getMessage('event') ?? [];
     $frmErrors = [];
     if ($request->isPost()) {
         $validator = new EventValidator($_POST);
         try {
             $validator->talkValidation()->dateValidation();
             if (!$validator->isValid()) {
                 throw new \Exception('Form not valid.');
             }
             $event = new \App\Model\Event\Event(new Talk(strip_tags($request->getParam('talk_title'), '<p><a><br>'), strip_tags($request->getParam('talk_description'), '<p><img><a><br>'), $this->eventManager->getSpeakerById((int) $request->getParam('speaker'))), $request->getParam('start_date'), $request->getParam('start_time'), $this->eventService->getVenueById($request->getParam('venue')), $this->eventManager->getSupporterByID($request->getParam('supporter')));
             $this->eventService->createEvent($event);
             if (!$request->getParam('meetup_id')) {
                 if ((int) $this->eventService->createMeetup()->getStatusCode() !== 201) {
                     throw new \Exception('Could not create meetup event.');
                 }
             } else {
                 // Do not create a meetup
                 $this->eventService->getMeetupEvent()->setEventID((int) $request->getParam('meetup_id'));
             }
             if ((int) $this->eventService->createJoindinEvent($this->eventSettings['name'], $this->eventSettings['description'])->getStatusCode() !== 201) {
                 $this->flash->addMessage('event', 'Could not create Joindin event. Please try again.');
                 return $response->withStatus(302)->withHeader('Location', '/create-event?meetup_id=' . $this->eventService->getMeetupEvent()->getMeetupEventID());
             }
             if ((int) $this->eventService->createJoindinTalk()->getStatusCode() !== 201) {
                 // TODO
                 // Delete meetup event and JoindIn event just created.
                 throw new \Exception('Could not create Joindin talk.');
             }
             $eventEntity = $this->eventService->updateEvents();
             return $response->withStatus(302)->withHeader('Location', '/event/' . $eventEntity->getId());
         } catch (\Exception $e) {
             $frmErrors = $validator->getErrors();
             $errors[] = $e->getMessage();
         }
     }
     $nameKey = $this->csrf->getTokenNameKey();
     $valueKey = $this->csrf->getTokenValueKey();
     $name = $request->getAttribute($nameKey);
     $value = $request->getAttribute($valueKey);
     $this->view->render($response, 'admin/create-event.twig', ['speakers' => $speakers, 'venues' => $venues, 'eventInfo' => $eventInfo, 'supporters' => $supporters, 'nameKey' => $nameKey, 'valueKey' => $valueKey, 'name' => $name, 'value' => $value, 'errors' => $errors, 'frmErrors' => $frmErrors]);
     return $response;
 }
开发者ID:Allan-Mapletoft,项目名称:website,代码行数:58,代码来源:CreateEventAction.php

示例6: editRota

 public function editRota(Request $request, Response $response, array $args)
 {
     $id = $this->authenticator->getIdentity();
     if (strtolower($id['name']) != 'admin') {
         $this->flash->addMessage('flash', 'Access Denied');
         return $response->withRedirect($this->router->pathFor('homepage'));
     }
     $name = $args['name'];
     if (empty($name)) {
         $this->flash->addMessage('flash', 'No rota specified');
         return $response->withRedirect($this->router->pathFor('rotas'));
     }
     if ($name != 'new') {
         $rota = R::findOrCreate('rotas', ['name' => $name]);
     } else {
         $rota = R::dispense('rotas');
     }
     if ($request->isPost()) {
         $data = $request->getParams();
         //$username = $request->getParam('username');
         $rota->import($data, 'name,fullname,title,comment');
         $rota->sharedUsersList = [];
         foreach ($data['users'] as $checkUserID) {
             $rotaUser = R::load('users', $checkUserID);
             $rota->sharedUsersList[] = $rotaUser;
         }
         $id = R::store($rota);
         try {
             $fieldtest = R::inspect($rota->name);
         } catch (\Exception $e) {
             //thaw for creation
             R::freeze(['users']);
             $rotaUser = R::load('users', 1);
             $rotaDay = R::findOrCreate($rota->name, ['day' => 29, 'month' => 2, 'year' => 2015]);
             $rotaUser = R::load('users', 1);
             $rotaDay->name = $rotaUser;
             $rotaDay->who = $rotaUser;
             $rotaDay->stamp = date("Y-m-d H:i:s");
             R::store($rotaDay);
             R::freeze(true);
         }
         $this->flash->addMessage('flash', "{$rota->name} updated");
         return $response->withRedirect($this->router->pathFor('rotas'));
     }
     $userList = R::findAll('users');
     $data = $rota->export();
     $data['userList'] = $userList;
     $users = [];
     $userRota = $rota->sharedUsersList;
     foreach ($userRota as $userCheck) {
         $users[$userCheck->id] = 'checked';
     }
     $data['userCheck'] = $users;
     $this->view->render($response, 'rota.twig', $data);
     return $response;
 }
开发者ID:aodkrisda,项目名称:oncallslim,代码行数:56,代码来源:RotaAction.php

示例7: dispatch

 public function dispatch(Request $request, Response $response, $args)
 {
     if ($request->isPost()) {
         $speaker = new Speaker(null, $request->getParam('first_name'), $request->getParam('last_name'), new Email($request->getParam('email')), new Twitter($request->getParam('twitter')));
         $msg = [];
         try {
             $this->speakersRepository->save($speaker);
             $msg['id'] = $speaker->id;
         } catch (\Exception $e) {
             return $response->withStatus(200)->withHeader('Content-Type', 'application/json')->write(json_encode(['error' => $e->getMessage()]));
         }
         return $response->withStatus(201)->withHeader('Content-Type', 'application/json')->write(json_encode($msg));
     }
 }
开发者ID:Allan-Mapletoft,项目名称:website,代码行数:14,代码来源:CreateSpeakerAction.php

示例8: dispatch

 /**
  * @param Request $request
  * @param Response $response
  * @param $args
  * @return Response
  */
 public function dispatch(Request $request, Response $response, $args)
 {
     $data = [];
     if ($request->isPost()) {
         $magnetUri = $request->getParam('magnetUri');
         if ($magnetUri) {
             $torrent = Torrent::fromMagnet($magnetUri);
             $data['torrent'] = $torrent;
             $data['torrentLink'] = (new Torcache())->getDownloadUrl($torrent);
         }
     }
     $this->view->render($response, 'home.twig', $data);
     return $response;
 }
开发者ID:amneale,项目名称:pibay,代码行数:20,代码来源:HomeAction.php

示例9: edit

 public function edit(Request $request, Response $response, array $args)
 {
     $uid = $args['uid'];
     if (empty($uid)) {
         $this->flash->addMessage('flash', 'No record specified');
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts'));
     }
     $id = $this->authenticator->getIdentity();
     $user = R::load('users', $id['id']);
     if ($uid != 'new') {
         $account = R::load('accounts', $uid);
         if ($account->id == 0) {
             $this->flash->addMessage('flash', 'No record found');
             return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts'));
         }
         // restrict access to own profile or Admin role
         if ($account->users->id != $id['id']) {
             if (strtolower($id['role']) != 'admin') {
                 $this->flash->addMessage('flash', 'Access Denied');
                 return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('accounts'));
             }
         }
     } else {
         $account = R::dispense('accounts');
     }
     if ($request->isPost()) {
         $data = $request->getParams();
         $account->import($data, 'apikey,accountid,servertype');
         $account->users = $user;
         $account->lasttid = 0;
         $oandaInfo = FALSE;
         // verify and get account balance
         try {
             $oandaInfo = new Broker_Oanda($account['servertype'], $account['apikey'], $account['accountid'], 0);
         } catch (\Exception $e) {
             $viewData['flash'] = 'Account Details Invalid';
         }
         if ($oandaInfo != FALSE) {
             $aid = R::store($account);
             $oandaInfo->updateAccount();
             $this->flash->addMessage('flash', "account updated");
             return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('editaccount', ['uid' => $aid]));
         }
     }
     $viewData['account'] = $account;
     $this->view->render($response, 'account.twig', $viewData);
     return $response;
 }
开发者ID:neilmillard,项目名称:fxtrader,代码行数:48,代码来源:AccountAction.php

示例10: __invoke

 public function __invoke(Request $req, Response $res)
 {
     if ($req->isPost()) {
         $adapter = $this->authService->getAdapter();
         if ($adapter instanceof ValidatableAdapterInterface) {
             $adapter->setIdentity($req->getParam('identity'));
             $adapter->setCredential($req->getParam('credential'));
         }
         $result = $this->authService->authenticate($adapter);
         if (!$result->isValid()) {
             $this->flash->addMessage('danger', reset($result->getMessages()));
             return $res->withRedirect($req->getUri());
         }
         return $res->withRedirect($this->successUrl);
     }
     return $this->view->render($res, 'user/login.twig', []);
 }
开发者ID:kanellov,项目名称:gredu_labs,代码行数:17,代码来源:Login.php

示例11: dispatch

 public function dispatch(Request $request, Response $response, $args)
 {
     $meetupID = $request->getAttribute('meetup_id', null);
     $eventInfo = $this->eventService->getInfoByMeetupID($meetupID);
     if ($eventInfo->eventExists()) {
         $this->flash->addMessage('event', 'Event already exists. Check its status.');
         return $response->withStatus(302)->withHeader('Location', 'event-details/' . $meetupID);
     }
     if (!$eventInfo->isRegistered() && !is_null($meetupID)) {
         $this->flash->addMessage('event', 'No event found for meetupID provided. Please create a new event.');
         return $response->withStatus(302)->withHeader('Location', 'create-event');
     }
     $form = new CreateEventForm($this->eventManager, $this->eventService);
     if ($eventInfo->isRegistered()) {
         $form->setEventInfo($eventInfo);
     }
     $data = ['form' => $form, 'errors' => $this->flash->getMessage('event') ?? [], 'defaultTime' => $this->eventsConfig->defaultStartTime];
     if ($request->isPost()) {
         $form->populate($request->getParams());
         if (!$form->isValid()) {
             // return response
             $data['errors'] = $form->getErrors();
             $data = array_merge($data, $this->getCsrfValues($request));
             $response->withStatus(304);
             $this->view->render($response, 'admin/create-event.twig', $data);
             return $response;
         }
         try {
             $event = EventFactory::getEvent($form->getTalkTitle(), $form->getTalkDescription(), $form->getEventDate(), $form->getSpeaker(), $form->getVenue(), $form->getSupporter(), $this->eventsConfig->title, $this->eventsConfig->description);
             $createEventInfo = $this->eventService->createMainEvents($event, $this->auth->getUserId(), $meetupID);
             if (!is_null($createEventInfo['joindin_message'])) {
                 $this->flash->addMessage('event', $createEventInfo['joindin_message']);
             }
             return $response->withStatus(302)->withHeader('Location', 'event-details?meetup_id=' . $createEventInfo['meetup_id']);
         } catch (\Exception $e) {
             $this->logger->debug($e->getMessage());
             $this->logger->debug(print_r($data['errors'], true));
             $data['errors'] = array_merge($data['errors'], [$e->getMessage()]);
         }
     }
     $data = array_merge($data, $this->getCsrfValues($request));
     $this->view->render($response, 'admin/create-event.twig', $data);
     return $response;
 }
开发者ID:phpminds,项目名称:website,代码行数:44,代码来源:CreateEventAction.php

示例12: editUser

 public function editUser(Request $request, Response $response, array $args)
 {
     $username = strtolower($args['username']);
     if (empty($username)) {
         $this->flash->addMessage('flash', 'No user specified');
         return $response->withRedirect($this->router->pathFor('profile'));
     }
     $id = $this->authenticator->getIdentity();
     // restrict access to own profile or Admin user
     if ($username != strtolower($id['name'])) {
         if (strtolower($id['name']) != 'admin') {
             $this->flash->addMessage('flash', 'Access Denied');
             return $response->withRedirect($this->router->pathFor('profile'));
         }
     }
     if ($username != 'new') {
         $user = R::findOrCreate('users', ['name' => $username]);
     } else {
         $user = R::dispense('users');
     }
     if ($request->isPost()) {
         $data = $request->getParams();
         //$username = $request->getParam('username');
         $user->import($data, 'fullname,shortdial,longdial,colour,mobile,home');
         $user->name = $request->getParam('username');
         $password = $request->getParam('password');
         if (!empty($password)) {
             $pass = password_hash($password, PASSWORD_DEFAULT);
             $user->hash = $pass;
         }
         $id = R::store($user);
         $this->flash->addMessage('flash', "{$user->name} updated");
         return $response->withRedirect($this->router->pathFor('edituser', ['username' => $username]));
         //            $member = 'INSERT INTO `users` (`name`, `fullname`, `password`, `hash`, `colour`, `shortdial`, `longdial`, `mobile`, `home`, `ins_mf`, `ins_win`, `health_mf`, `health_win`, `life_mf`, `life_win`, `wealth_mf`, `wealth_win`, `uk_shift`, `atss`) VALUES '
         //                . "($username, $fullname, :pass, '', 'FAD2F5', $shortdial, $longdial, '', '', '1', '0', '0', '1', '0', '0', '0', '1', '0', '0');
         //                ";
     }
     $this->view->render($response, 'user.twig', $user->export());
     return $response;
 }
开发者ID:aodkrisda,项目名称:oncallslim,代码行数:40,代码来源:ProfileAction.php

示例13: dispatch

 public function dispatch(Request $request, Response $response, $args)
 {
     // CSRF token name and value
     $nameKey = $this->csrf->getTokenNameKey();
     $valueKey = $this->csrf->getTokenValueKey();
     $name = $request->getAttribute($nameKey);
     $value = $request->getAttribute($valueKey);
     $email = '';
     $msg = '';
     if ($request->isPost()) {
         $email = $request->getParam('email');
         $password = $request->getParam('password');
         if ($this->auth->isValid($email, $password)) {
             $this->auth->store();
             return $response->withStatus(302)->withHeader('Location', '/');
         } else {
             $msg = 'Incorrect email or password.';
         }
     }
     $this->view->render($response, 'login.twig', ['nameKey' => $nameKey, 'valueKey' => $valueKey, 'name' => $name, 'value' => $value, 'email' => $email, 'msg' => $msg]);
     return $response;
 }
开发者ID:Allan-Mapletoft,项目名称:website,代码行数:22,代码来源:LoginAction.php

示例14: editUser

 public function editUser(Request $request, Response $response, array $args)
 {
     $username = strtolower($args['username']);
     if (empty($username)) {
         $this->flash->addMessage('flash', 'No user specified');
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('profile'));
     }
     $id = $this->authenticator->getIdentity();
     // restrict access to own profile or Admin user
     if ($username != strtolower($id['name'])) {
         if (strtolower($id['name']) != 'admin') {
             $this->flash->addMessage('flash', 'Access Denied');
             return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('profile'));
         }
     }
     if ($username != 'new') {
         $user = R::findOrCreate('users', ['name' => $username]);
     } else {
         $user = R::dispense('users');
     }
     if ($request->isPost()) {
         $data = $request->getParams();
         //$username = $request->getParam('username');
         $user->import($data, 'fullname,colour,mobile,home');
         $user->name = $request->getParam('username');
         $password = $request->getParam('password');
         if (!empty($password)) {
             $pass = password_hash($password, PASSWORD_DEFAULT);
             $user->hash = $pass;
         }
         $id = R::store($user);
         $this->flash->addMessage('flash', "{$user->name} updated");
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('edituser', ['username' => $username]));
     }
     $this->view->render($response, 'user.twig', $user->export());
     return $response;
 }
开发者ID:neilmillard,项目名称:slim3skel,代码行数:37,代码来源:ProfileAction.php

示例15: editUser

 public function editUser(Request $request, Response $response, array $args)
 {
     $username = $args['username'];
     if (empty($username)) {
         $this->flash->addMessage('flash', 'No user specified');
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('profile'));
     }
     $username = base64_decode($username);
     $id = $this->authenticator->getIdentity();
     // restrict access to own profile or Admin role
     if ($username != strtolower($id['email'])) {
         if (strtolower($id['role']) != 'admin') {
             $this->flash->addMessage('flash', 'Access Denied');
             return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('profile'));
         }
     }
     $user = R::findOne('users', ' email = ? ', [$username]);
     if ($user == NULL) {
         $user = R::dispense('users');
     }
     if ($request->isPost()) {
         $user->fullname = $request->getParam('userfullname');
         $user->email = $request->getParam('username');
         $password = $request->getParam('userpassword');
         if (!empty($password)) {
             $pass = password_hash($password, PASSWORD_DEFAULT);
             $user->hash = $pass;
         }
         $id = R::store($user);
         $this->flash->addMessage('flash', "{$user->name} updated");
         return $response->withRedirect($request->getUri()->getBaseUrl() . $this->router->pathFor('edituser', ['username' => base64_encode($username)]));
     }
     $expUser['user'] = $user->export();
     $expUser['user']['hashemail'] = base64_encode($user['email']);
     $this->view->render($response, 'user.twig', $expUser);
     return $response;
 }
开发者ID:neilmillard,项目名称:fxtrader,代码行数:37,代码来源:ProfileAction.php


注:本文中的Slim\Http\Request::isPost方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。