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


PHP Request::isMethod方法代码示例

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


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

示例1: indexAction

 /**
  * Reference purchase summary
  *
  * @Route()
  * @Method({"GET", "POST"})
  * @Template()
  *
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function indexAction(Request $request)
 {
     $previouslyPostedData = null;
     // if we are not posting new data, and a request for $this->formType is stored in the session, prepopulate the form with the stored request
     $storedRequest = unserialize($request->getSession()->get($this->formType->getName()));
     if ($request->isMethod('GET') && $storedRequest instanceof Request) {
         $previouslyPostedData = $this->createForm($this->formType)->handleRequest($storedRequest)->getData();
     }
     $form = $this->createForm($this->formType, $previouslyPostedData);
     if ($request->isMethod('POST')) {
         $form->submit($request);
         if ($form->isValid()) {
             // Persist the case to IRIS
             /** @var ReferencingCase $case */
             $case = $form->getData()['case'];
             $this->irisEntityManager->persist($case);
             /** @var ReferencingApplication $application */
             foreach ($case->getApplications() as $application) {
                 // Always default
                 $application->setSignaturePreference(SignaturePreference::SCAN_DECLARATION);
                 $this->irisEntityManager->persist($application, array('caseId' => $case->getCaseId()));
                 // Persist each guarantor of the application
                 if (null !== $application->getGuarantors()) {
                     foreach ($application->getGuarantors() as $guarantor) {
                         $this->irisEntityManager->persist($guarantor, array('applicationId' => $application->getApplicationId()));
                     }
                 }
             }
             $request->getSession()->set('submitted-case', serialize($case));
             // Send the user to the success page
             return $this->redirect($this->generateUrl('barbon_hostedapi_agent_reference_newreference_tenancyagreement_index'), 301);
         }
     }
     return array('form' => $form->createView());
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:45,代码来源:NewController.php

示例2: process

 /**
  * @param FormInterface $form
  * @param Request $request
  * @return AccountUser|bool
  */
 public function process(FormInterface $form, Request $request)
 {
     if ($request->isMethod('POST')) {
         $form->submit($request);
         if ($form->isValid()) {
             $email = $form->get('email')->getData();
             /** @var AccountUser $user */
             $user = $this->userManager->findUserByUsernameOrEmail($email);
             if ($this->validateUser($form, $email, $user)) {
                 if (null === $user->getConfirmationToken()) {
                     $user->setConfirmationToken($user->generateToken());
                 }
                 try {
                     $this->userManager->sendResetPasswordEmail($user);
                     $user->setPasswordRequestedAt(new \DateTime('now', new \DateTimeZone('UTC')));
                     $this->userManager->updateUser($user);
                     return $user;
                 } catch (\Exception $e) {
                     $this->addFormError($form, 'oro.email.handler.unable_to_send_email');
                 }
             }
         }
     }
     return false;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:30,代码来源:AccountUserPasswordRequestHandler.php

示例3: editAction

 /**
  * Add a new Article or edit an existing Article
  * @return \Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function editAction()
 {
     $slug = $this->request->get('slug');
     if ($slug === null) {
         $article = new Article();
     } else {
         $article = $this->articleService->getArticleBySlug($slug);
         if (empty($article)) {
             return $this->redirect($this->generateUrl('article_dashboard'));
         }
     }
     $form = $this->createForm(new ArticleType(), $article);
     if ($this->request->isMethod('POST')) {
         $form->handleRequest($this->request);
         if ($form->isValid()) {
             $file = $form->get('file')->getData();
             $uniqueFileName = $this->uploadService->uploadFile($file);
             $article->setPictureName($uniqueFileName);
             $article->setAuthor($this->getUser());
             $this->articleService->save($article);
             return $this->redirect($this->generateUrl('article_view', array('slug' => $article->getSlug())));
         }
     }
     return $this->render('AppBundle:Article:edit.html.twig', array('form' => $form->createView()));
 }
开发者ID:baptistelinel,项目名称:Administrable-Blog,代码行数:29,代码来源:ArticleController.php

示例4: ajaxEditGlobalAwardAction

 public function ajaxEditGlobalAwardAction()
 {
     $globalAward = $this->getDoctrine()->getRepository('HelperBundle:GlobalAward')->find($this->request->get('globalAwardId', 0));
     if (!$globalAward) {
         throw $this->createNotFoundException('Invalid global award');
     }
     $propertyType = $this->get('services.institution_property')->getAvailablePropertyType(InstitutionPropertyType::TYPE_GLOBAL_AWARD);
     $imcProperty = $this->imcService->getPropertyValue($this->institutionMedicalCenter, $propertyType, $globalAward->getId(), $this->request->get('propertyId', 0));
     $imcProperty->setValueObject($globalAward);
     $editGlobalAwardForm = $this->createForm(new InstitutionGlobalAwardFormType(), $imcProperty);
     if ($this->request->isMethod('POST')) {
         $editGlobalAwardForm->bind($this->request);
         if ($editGlobalAwardForm->isValid()) {
             $imcProperty = $editGlobalAwardForm->getData();
             $em = $this->getDoctrine()->getEntityManager();
             $em->persist($imcProperty);
             $em->flush();
             // Invalidate InstitutionMedicalCenterProfile memcache
             $this->get('services.memcache')->delete(FrontendMemcacheKeysHelper::generateInsitutionMedicalCenterProfileKey($this->institutionMedicalCenter->getId()));
             $output = array('status' => true, 'extraValue' => $imcProperty->getExtraValue());
             $response = new Response(\json_encode($output), 200, array('content-type' => 'application/json'));
         } else {
             $response = new Response('Form error', 400);
         }
     }
     return $response;
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:27,代码来源:MedicalCenterPropertiesController.php

示例5: process

 /**
  * Prepare & process form
  *
  * @author Jeremie Samson <jeremie@ylly.fr>
  *
  * @return bool
  */
 public function process()
 {
     if ($this->request->isMethod('POST')) {
         $this->form->handleRequest($this->request);
         if ($this->form->isValid()) {
             /** @var ModelUserRole $model */
             $model = $this->form->getData();
             if (!$model->getUser() || !$model->getRole()) {
                 $this->form->addError(new FormError('Missing parameter(s)'));
             }
             /** @var User $user */
             $user = $this->em->getRepository('UserBundle:User')->find($model->getUser());
             /** @var Post $role */
             $role = $this->em->getRepository('FaucondorBundle:Post')->find($model->getRole());
             if (!$user) {
                 $this->form->get('user')->addError(new FormError('User with id ' . $model->getUser() . ' not found '));
             }
             if (!$role) {
                 $this->form->get('role')->addError(new FormError('Role with id ' . $model->getRole() . ' not found '));
             }
             $this->onSuccess($user, $role);
             return true;
         }
     }
     return false;
 }
开发者ID:ESNFranceG33kTeam,项目名称:sf_faucondor,代码行数:33,代码来源:UserRoleHandler.php

示例6: canRedirect

 /**
  * Determines if redirect may be performed.
  *
  * @param Request $request
  *   The current request object.
  * @param string $route_name
  *   The current route name.
  *
  * @return bool
  *   TRUE if redirect may be performed.
  */
 public function canRedirect(Request $request, $route_name = NULL)
 {
     $can_redirect = TRUE;
     if (isset($route_name)) {
         $route = $this->routeProvider->getRouteByName($route_name);
         if ($this->config->get('access_check')) {
             // Do not redirect if is a protected page.
             $can_redirect = $this->accessManager->checkNamedRoute($route_name, [], $this->account);
         }
     } else {
         $route = $request->attributes->get(RouteObjectInterface::ROUTE_OBJECT);
     }
     if (strpos($request->getScriptName(), 'index.php') === FALSE) {
         // Do not redirect if the root script is not /index.php.
         $can_redirect = FALSE;
     } elseif (!($request->isMethod('GET') || $request->isMethod('HEAD'))) {
         // Do not redirect if this is other than GET request.
         $can_redirect = FALSE;
     } elseif ($this->state->get('system.maintenance_mode') || defined('MAINTENANCE_MODE')) {
         // Do not redirect in offline or maintenance mode.
         $can_redirect = FALSE;
     } elseif ($this->config->get('ignore_admin_path') && isset($route)) {
         // Do not redirect on admin paths.
         $can_redirect &= !(bool) $route->getOption('_admin_route');
     }
     return $can_redirect;
 }
开发者ID:CIGIHub,项目名称:bsia-drupal8,代码行数:38,代码来源:RedirectChecker.php

示例7: ajoutDetailsWEIAction

 public function ajoutDetailsWEIAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     if ($request->isMethod('POST')) {
         $id = $_POST['id'];
     } else {
         $id = $_GET['id'];
     }
     $detailsWEI = $this->serviceMembre->GetDetailsByIdEtudiant($id);
     if ($detailsWEI == NULL) {
         $detailsWEI = new DetailsWEI();
     }
     $etu = $this->serviceMembre->GetEtudiantById($id);
     if (boolval($em->getRepository("BdEMainBundle:Config")->get("wei.bungMixtes"))) {
         $sexeEtu = -1;
     } elseif ($etu->getCivilite() == "M") {
         $sexeEtu = "M";
     } else {
         $sexeEtu = "F";
     }
     $form = $this->createForm(new DetailsWEIType($sexeEtu, $detailsWEI->getBus(), $detailsWEI->getBungalow()), $detailsWEI);
     if ($request->isMethod('POST')) {
         $form->bind($request);
         if ($form->isValid()) {
             $bizuth = $this->serviceMembre->GetEtudiantById($request->request->get('id'));
             $detailsWEI->setIdEtudiant($bizuth);
             $em->persist($detailsWEI);
             $em->flush();
             $this->get('session')->getFlashBag()->add('notice', 'Details enregistres');
             return $this->redirect($this->generateUrl('bde_wei_inscription_rechercheBizuthWEI'));
         }
     }
     return $this->render('BdEWeiBundle:Default:ajoutDetailsWEI.html.twig', array('form' => $form->createView(), 'id' => $request->query->get('id')));
 }
开发者ID:PhilippeGeek,项目名称:adhesion,代码行数:34,代码来源:DefaultController.php

示例8: process

 /**
  * Prepare & process form
  *
  * @author Jeremie Samson <jeremie@ylly.fr>
  *
  * @return bool
  */
 public function process()
 {
     if ($this->request->isMethod('POST')) {
         $this->form->handleRequest($this->request);
         if ($this->form->isValid()) {
             /** @var ModelUser $user */
             $user = $this->form->getData();
             if (!$user->getFirstname() || !$user->getLastname() || !$user->getEmailGalaxy() || !$user->getSection()) {
                 $this->form->addError(new FormError('Missing parameter(s)'));
             } else {
                 if (!filter_var($user->getEmail(), FILTER_VALIDATE_EMAIL) || !filter_var($user->getEmailGalaxy(), FILTER_VALIDATE_EMAIL)) {
                     $error = new FormError('email invalid');
                     if (!filter_var($user->getEmail(), FILTER_VALIDATE_EMAIL)) {
                         $this->form->get('email')->addError($error);
                     }
                     if (!filter_var($user->getEmailGalaxy(), FILTER_VALIDATE_EMAIL)) {
                         $this->form->get('emailGalaxy')->addError($error);
                     }
                 } else {
                     $section_id = $this->em->getRepository('FaucondorBundle:Section')->find($user->getSection());
                     $section_code = $this->em->getRepository('FaucondorBundle:Section')->findOneBy(array("code" => $user->getSection()));
                     if (!$section_id && !$section_code) {
                         $this->form->get('section')->addError(new FormError('Section with id ' . $user->getSection() . ' not found'));
                     } else {
                         /** @var Section $section */
                         $section = $section_id ? $section_id : $section_code;
                         $this->onSuccess($user, $section);
                         return true;
                     }
                 }
             }
         }
     }
     return false;
 }
开发者ID:ESNFranceG33kTeam,项目名称:sf_faucondor,代码行数:42,代码来源:UserHandler.php

示例9: getHttpVars

 /**
  *
  */
 public function getHttpVars() : array
 {
     if ($this->request->isMethod('POST')) {
         $http_vars = $this->request->request->all();
     } else {
         $http_vars = $this->request->query->all();
     }
     return $http_vars;
 }
开发者ID:dqneo,项目名称:ethnam,代码行数:12,代码来源:RequestWrapper.php

示例10: getRequestParameters

 /**
  * Returns the GET or POST parameters form the request.
  *
  * @return ParameterBag
  */
 protected function getRequestParameters()
 {
     if ($this->request->isMethod('POST')) {
         $parameters = $this->request->request;
     } else {
         $parameters = $this->request->query;
     }
     return $parameters;
 }
开发者ID:ybensacq,项目名称:LexikPayboxBundle,代码行数:14,代码来源:Response.php

示例11: apply

 public function apply(Request $request, ParamConverter $configuration)
 {
     if ($request->isMethod('POST') && !empty($configuration->getOptions()['request_path'])) {
         $requestPath = $configuration->getOptions()['request_path'];
         $request->attributes->set($requestPath, $request->request->get($requestPath));
     } elseif ($request->isMethod('GET') && !empty($configuration->getOptions()['query_path'])) {
         $queryPath = $configuration->getOptions()['query_path'];
         $request->attributes->set($queryPath, $request->query->get($queryPath));
     }
     return parent::apply($request, $configuration);
 }
开发者ID:Briareos,项目名称:Undine,代码行数:11,代码来源:DoctrineParamConverter.php

示例12: process

 /**
  * Process form
  *
  * @param RFPRequest $rfpRequest
  * @return bool True on successful processing, false otherwise
  */
 public function process(RFPRequest $rfpRequest)
 {
     if ($this->request->isMethod('POST')) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             $this->onSuccess($rfpRequest);
             return true;
         }
     }
     return false;
 }
开发者ID:hafeez3000,项目名称:orocommerce,代码行数:17,代码来源:RequestChangeStatusHandler.php

示例13: process

 /**
  * @param Quote $quote
  * @return Order|null
  */
 public function process(Quote $quote)
 {
     $this->form->setData($quote);
     if ($this->request->isMethod('POST')) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             return $this->onSuccess($quote, $this->form->getData());
         }
     }
     return null;
 }
开发者ID:adam-paterson,项目名称:orocommerce,代码行数:15,代码来源:QuoteToOrderHandler.php

示例14: process

 /**
  * {@inheritdoc}
  */
 public function process($entity)
 {
     $this->form->setData($entity);
     if ($this->request->isMethod('POST')) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             $this->saver->save($entity);
             return true;
         }
     }
     return false;
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:15,代码来源:BaseHandler.php

示例15: process

 /**
  * Process method for handler
  * @param AssociationType $associationType
  *
  * @return boolean
  */
 public function process(AssociationType $associationType)
 {
     $this->form->setData($associationType);
     if ($this->request->isMethod('POST')) {
         $this->form->submit($this->request);
         if ($this->form->isValid()) {
             $this->onSuccess($associationType);
             return true;
         }
     }
     return false;
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:18,代码来源:AssociationTypeHandler.php


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