本文整理汇总了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());
}
示例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;
}
示例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()));
}
示例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;
}
示例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;
}
示例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;
}
示例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')));
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}