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


PHP Request::isXmlHttpRequest方法代码示例

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


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

示例1: indexAction

 /**
  * @Route("/{applicationId}")
  * @Method({"GET", "POST"})
  * @Template()
  * @param Request $request
  * @param $applicationId
  * @return array
  */
 public function indexAction(Request $request, $applicationId)
 {
     // Validate the $applicationId, throws Exception if invalid.
     $application = $this->getApplication($this->irisEntityManager, $applicationId);
     // Get the Case for this Tenant and put in the session, as it's needed throughout
     $case = $this->getCase($this->irisEntityManager, $application->getCaseId());
     $request->getSession()->set('submitted-case', serialize($case));
     // Create an empty ReferencingGuarantor object.
     $guarantor = new ReferencingGuarantor();
     $guarantor->setCaseId($application->getCaseId());
     // Build the form.
     $form = $this->createForm($this->formType, $guarantor, array('guarantor_decorator' => $this->referencingGuarantorDecoratorBridgeSubscriber->getGuarantorDecorator(), 'attr' => array('id' => 'generic_step_form', 'class' => 'referencing branded individual-guarantor-form', 'novalidate' => 'novalidate')));
     // Process a client round trip, if necessary
     if ($request->isXmlHttpRequest()) {
         $form->submit($request);
         return $this->render('BarbonHostedApiLandlordReferenceBundle:NewReference/Guarantor/Validate:index.html.twig', array('form' => $form->createView()));
     }
     // Submit the form.
     $form->handleRequest($request);
     if ($form->isValid()) {
         $case = $this->getCase($this->irisEntityManager, $application->getCaseId());
         // Dispatch the new guarantor reference event.
         $this->eventDispatcher->dispatch(NewReferenceEvents::GUARANTOR_REFERENCE_CREATED, new NewGuarantorReferenceEvent($case, $application, $guarantor));
         // Send the user to the success page.
         return $this->redirectToRoute('barbon_hostedapi_landlord_reference_newreference_guarantor_confirmation_index', array('applicationId' => $applicationId));
     }
     return array('form' => $form->createView());
 }
开发者ID:AlexEvesDeveloper,项目名称:hl-stuff,代码行数:36,代码来源:NewController.php

示例2: showEditHistoryAction

 /**
  * Show edit history of an object
  * Required REQUEST parameters are:
  *     objectId - int
  *     objectClass - base64_encoded fully qualified class name
  * 
  * @param Request $request
  * @return \HealthCareAbroad\AdminBundle\Controller\Response
  */
 public function showEditHistoryAction(Request $request)
 {
     if (!$request->isXmlHttpRequest()) {
         //throw $this->createNotFoundException("Only supports AJAX request");
     }
     $objectId = $request->get('objectId', null);
     $objectClass = $request->get('objectClass', null);
     if ($objectId === null || $objectClass === null) {
         return new Response("objectId and objectClass are required parameters", 400);
     }
     $objectClass = \base64_decode($objectClass);
     if (!\class_exists($objectClass)) {
         throw $this->createNotFoundException("Cannot view history of invalid class {$objectClass}");
     }
     $object = $this->getDoctrine()->getRepository($objectClass)->find($objectId);
     if (!$object) {
         throw $this->createNotFoundException("Object #{$objectId} of class {$objectClass} does not exist.");
     }
     $service = $this->get('services.log.entity_version');
     $versionEntries = $service->getObjectVersionEntries($object);
     $template = 'InstitutionBundle:History:editHistory.html.twig';
     if ($request->isXmlHttpRequest()) {
         $template = 'InstitutionBundle:History:versionList.html.twig';
     }
     $objectName = $object->__toString();
     return $this->render($template, array('versions' => $versionEntries, 'objectName' => $objectName));
 }
开发者ID:TMBaay,项目名称:MEDTrip---Healthcareabroad,代码行数:36,代码来源:HistoryController.php

示例3: render

 /**
  * {@inheritdoc}
  */
 public function render($name, array $parameters = array())
 {
     if ($this->request->isXmlHttpRequest()) {
         return $this->engine->render($name, $parameters);
     }
     if (!$this->admin->inAdmin() || $this->isRender || in_array($name, ['GloryAdminBundle:Security:login.html.twig'])) {
         return $this->engine->render($name, $parameters);
     }
     $this->isRender = true;
     $layoutName = 'GloryAdminBundle::layout.html.twig';
     $template = $this->load($name);
     if (in_array($layoutName, $this->getTemplates($template))) {
         return $this->engine->render($name, $parameters);
     }
     $layout = $this->load($layoutName);
     $blocks = $this->getBlocks($template, $parameters);
     //        $blocks = [];
     //        foreach (['title', 'stylesheets', 'javascripts', 'content'] as $name) {
     //            if (false !== $block = $this->getBlock($template, $name)) {
     //                $blocks[$name] = $block;
     //            }
     //        }
     ob_start();
     try {
         $layout->display($parameters, $blocks);
     } catch (\Exception $e) {
         ob_end_clean();
         throw $e;
     }
     return ob_get_clean();
 }
开发者ID:foreverglory,项目名称:admin-bundle,代码行数:34,代码来源:TwigEngine.php

示例4: indexAction

 public function indexAction(Request $request)
 {
     /** @var $em EntityManager */
     /** @var AssetClassRepository $repo */
     $em = $this->get('doctrine.orm.entity_manager');
     $repo = $em->getRepository('WealthbotAdminBundle:AssetClass');
     /** @var User $ria */
     $ria = $this->getUser();
     $selectedModel = $ria->getRiaCompanyInformation()->getPortfolioModel();
     $riaCompanyInfo = $ria->getRiaCompanyInformation();
     $isShowExpectedAsset = $riaCompanyInfo->getIsShowClientExpectedAssetClass();
     $isShowAccountType = $this->isShowAccountType($riaCompanyInfo);
     $isShowPriority = false;
     //$riaCompanyInfo->isShowSubclassPriority();
     $accountTypes = $em->getRepository('WealthbotRiaBundle:SubclassAccountType')->findAll();
     $assetClasses = $repo->findByModelIdAndOwnerId($selectedModel->getId(), $ria->getId());
     //var_dump($selectedModel->getId(), $assetClasses);die;
     $assets = new AssetCollection($assetClasses, $selectedModel);
     $options = array('original_assets' => $assetClasses, 'original_subclasses' => $this->collectOriginalSubclassesForAssets($assetClasses));
     $form = $this->createForm(new CategoriesFormType($ria, $em), $assets);
     $formHandler = new CategoriesFormHandler($form, $request, $em, $options);
     if ($request->isMethod('post') && $formHandler->process()) {
         if ($request->isXmlHttpRequest()) {
             return $this->getJsonResponse(array('status' => 'success', 'success_url' => $this->generateUrl('rx_ria_dashboard_models_tab', array('tab' => 'categories'))));
         }
         return $this->redirect($this->generateUrl('rx_ria_dashboard_models_tab', array('tab' => 'categories')));
     }
     if ($request->isXmlHttpRequest()) {
         $content = $this->renderView('WealthbotRiaBundle:Categories:index.html.twig', array('form' => $form->createView(), 'is_show_expected_asset' => $isShowExpectedAsset, 'is_show_account_type' => $isShowAccountType, 'is_show_priority' => $isShowPriority, 'is_show_tolerance_band' => $riaCompanyInfo->isRebalancedFrequencyToleranceBand(), 'account_types' => $accountTypes));
         return $this->getJsonResponse(array('status' => 'form', 'content' => $content));
     }
     return $this->render('WealthbotRiaBundle:Categories:index.html.twig', array('form' => $form->createView(), 'is_show_expected_asset' => $isShowExpectedAsset, 'is_show_account_type' => $isShowAccountType, 'is_show_priority' => $isShowPriority, 'is_show_tolerance_band' => $riaCompanyInfo->isRebalancedFrequencyToleranceBand(), 'account_types' => $accountTypes));
 }
开发者ID:junjinZ,项目名称:wealthbot,代码行数:33,代码来源:CategoriesController.php

示例5: indexAction

 public function indexAction(Request $request)
 {
     /** @var $em EntityManager */
     /** @var AssetClassRepository $repo */
     $em = $this->get('doctrine.orm.entity_manager');
     $repo = $em->getRepository('WealthbotAdminBundle:AssetClass');
     $user = $this->getUser();
     $model = $em->getRepository('WealthbotAdminBundle:CeModel')->find($request->get('model_id'));
     $accountTypes = $em->getRepository('WealthbotRiaBundle:SubclassAccountType')->findAll();
     $assetClasses = $repo->findWithSubclassesByModelIdAndOwnerId($model->getId(), null);
     $assets = new AssetCollection($assetClasses, $model);
     $options = array('original_assets' => $assetClasses, 'original_subclasses' => $this->collectOriginalSubclassesForAssets($assetClasses));
     $form = $this->createForm(new CategoriesFormType($user, $em), $assets);
     $formHandler = new CategoriesFormHandler($form, $request, $em, $options);
     if ($request->isMethod('post') && $formHandler->process()) {
         if ($request->isXmlHttpRequest()) {
             return $this->getJsonResponse(array('status' => 'success', 'success_url' => $this->generateUrl('rx_admin_models_index_strategy', array('slug' => $model->getSlug()))));
         }
         return $this->redirect($this->generateUrl('rx_admin_models_index_strategy', array('slug' => $model->getSlug())));
     }
     if ($request->isXmlHttpRequest()) {
         $content = $this->renderView('WealthbotAdminBundle:Categories:index.html.twig', array('form' => $form->createView(), 'is_show_expected_asset' => true, 'is_show_account_type' => true, 'is_show_priority' => false, 'account_types' => $accountTypes));
         return $this->getJsonResponse(array('status' => 'form', 'content' => $content));
     }
     return $this->render('WealthbotAdminBundle:Categories:index.html.twig', array('form' => $form->createView(), 'is_show_expected_asset' => true, 'is_show_account_type' => true, 'is_show_priority' => false, 'account_types' => $accountTypes));
 }
开发者ID:junjinZ,项目名称:wealthbot,代码行数:26,代码来源:CategoriesController.php

示例6: loginAction

 public function loginAction(Request $request)
 {
     /** @var $session \Symfony\Component\HttpFoundation\Session\Session */
     $session = $request->getSession();
     // get the error if any (works with forward and redirect -- see below)
     if ($request->attributes->has(SecurityContext::AUTHENTICATION_ERROR)) {
         $error = $request->attributes->get(SecurityContext::AUTHENTICATION_ERROR);
     } elseif (null !== $session && $session->has(SecurityContext::AUTHENTICATION_ERROR)) {
         $error = $session->get(SecurityContext::AUTHENTICATION_ERROR);
         $session->remove(SecurityContext::AUTHENTICATION_ERROR);
     } else {
         $error = '';
     }
     if ($error) {
         // TODO: this is a potential security risk (see http://trac.symfony-project.org/ticket/9523)
         $error = $error->getMessage();
     }
     // last username entered by the user
     $lastUsername = null === $session ? '' : $session->get(SecurityContext::LAST_USERNAME);
     // we register the username in session used in dispatcherLoginFailureResponse
     $session->set('login-username', $lastUsername);
     // we test if the number of attempts allowed connections number with the username have been exceeded.
     if (!empty($lastUsername) && $this->container->has('sfynx.auth.dispatcher.login_failure.change_response')) {
         $key = $this->container->get('sfynx.auth.dispatcher.login_failure.change_response')->getKeyValue();
         if ($key == "stop-client") {
             $session->set('login-username', '');
             $session->remove(SecurityContext::LAST_USERNAME);
             if ($request->isXmlHttpRequest()) {
                 $response = new Response(json_encode('error'));
                 $response->headers->set('Content-Type', 'application/json');
                 return $response;
             } else {
                 $new_url = $this->container->get('router')->generate('fos_user_security_login');
                 $session->getFlashBag()->add('errorform', "you exceeded the number of attempts allowed connections!");
                 return new RedirectResponse($new_url);
             }
         }
     }
     $csrfToken = $this->container->has('form.csrf_provider') ? $this->container->get('form.csrf_provider')->generateCsrfToken('authenticate') : null;
     if ($request->isXmlHttpRequest()) {
         if ($error) {
             $statut = "error";
         } else {
             $statut = "ok";
         }
         $response = new Response(json_encode($statut));
         $response->headers->set('Content-Type', 'application/json');
         return $response;
     }
     return $this->renderLogin(array('last_username' => $lastUsername, 'error' => $error, 'csrf_token' => $csrfToken, 'NoLayout' => $this->container->get('request')->query->get('NoLayout')));
 }
开发者ID:pigroupe,项目名称:SfynxAuthBundle,代码行数:51,代码来源:SecurityController.php

示例7: doExecute

 /**
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|Response
  */
 public function doExecute(Request $request)
 {
     if (!$request->isXmlHttpRequest()) {
         return new RedirectResponse($this->getRedirectPath(null));
     }
     return parent::doExecute($request);
 }
开发者ID:ronanguilloux,项目名称:CustomEntityBundle,代码行数:12,代码来源:QuickCreateAction.php

示例8: ajaxIndexAction

 /**
  * Returns all attribute groups as json
  *
  * @param Request $request
  *
  * @return \Symfony\Component\HttpFoundation\JsonResponse|\Symfony\Component\HttpFoundation\RedirectResponse
  */
 public function ajaxIndexAction(Request $request)
 {
     if (!$request->isXmlHttpRequest()) {
         return $this->redirectToAction('index');
     }
     return $this->jsonResponse(['sets' => $this->manager->getAttributeGroupSet()]);
 }
开发者ID:raizeta,项目名称:WellCommerce,代码行数:14,代码来源:AttributeGroupController.php

示例9: updateAjaxSessionAction

 /**
  * @param $id
  * @param Request $request
  * @return JsonResponse
  */
 public function updateAjaxSessionAction($id, Request $request)
 {
     if (!$request->isXmlHttpRequest()) {
         throw new NotFoundHttpException('This action need to be call with AJAX');
     }
     $session = $request->getSession();
     $em = $this->getDoctrine()->getManager();
     $cart = $session->get('carts');
     $json = [];
     $qte = $request->query->get('qte');
     $pu = $request->query->get('pu');
     if ($qte !== null) {
         $cart[$id] = $qte;
         $json['sec'] = sprintf('Nouvelle quantité %s, pour la clé %s', $qte, $id);
         $json['qte'] = $qte;
         $json['totalpu'] = $pu * $qte;
         $session->set('carts', $cart);
         $session->save();
         //Calcul du total
         $products = $this->getProductCart($em, $cart);
         $total = $this->getShopTotal($products, $cart);
         $json['total'] = $total;
     }
     return new JsonResponse(['json' => $json]);
 }
开发者ID:raphydev,项目名称:onep,代码行数:30,代码来源:PanierController.php

示例10: editAction

 /**
  * The method that is executed when the user performs a 'edit' action on an entity.
  *
  * @return RedirectResponse|Response
  */
 protected function editAction()
 {
     $this->dispatch(EasyAdminEvents::PRE_EDIT);
     if ($this->request->isXmlHttpRequest()) {
         return $this->ajaxEdit();
     }
     $id = $this->request->query->get('id');
     $entity = $this->findCurrentEntity();
     $fields = $this->entity['edit']['fields'];
     if (method_exists($this, $customMethodName = 'create' . $this->entity['name'] . 'EditForm')) {
         $editForm = $this->{$customMethodName}($entity, $fields);
     } else {
         $editForm = $this->createEditForm($entity, $fields);
     }
     $deleteForm = $this->createDeleteForm($this->entity['name'], $id);
     $editForm->handleRequest($this->request);
     if ($editForm->isValid()) {
         $this->dispatch(EasyAdminEvents::PRE_UPDATE, array('entity' => $entity));
         if (method_exists($this, $customMethodName = 'preUpdate' . $this->entity['name'] . 'Entity')) {
             $this->{$customMethodName}($entity);
         } else {
             $this->preUpdateEntity($entity);
         }
         $this->em->flush();
         $this->dispatch(EasyAdminEvents::POST_UPDATE, array('entity' => $entity));
         $refererUrl = $this->request->query->get('referer', '');
         return !empty($refererUrl) ? $this->redirect(urldecode($refererUrl)) : $this->redirect($this->generateUrl('admin', array('action' => 'list', 'entity' => $this->entity['name'])));
     }
     $this->dispatch(EasyAdminEvents::POST_EDIT);
     return $this->render($this->entity['templates']['edit'], array('form' => $editForm->createView(), 'entity_fields' => $fields, 'entity' => $entity, 'delete_form' => $deleteForm->createView()));
 }
开发者ID:rkueny,项目名称:EasyAdminBundle,代码行数:36,代码来源:AdminController.php

示例11: listAction

 public function listAction(Request $request, $filter)
 {
     $user = $this->getUser();
     $em = $this->getDoctrine()->getManager();
     if ($user != null) {
         $request->setLocale($user);
         $listEvent = null;
         $listEvent = $em->getRepository('MdyXlagendaBundle:Event')->listEvents(null);
         return $this->render('MdyXlagendaBundle:Event:list.html.twig', array('listEvent' => $listEvent, 'filter' => $filter));
     } else {
         // utilisateur anonymous
         if ($request->isXmlHttpRequest()) {
             // il s'agit d'un appel AJAX
             if ($request->getMethod() == "POST") {
                 $filter = array();
                 $filter['lieu'] = $request->request->get('lieu');
                 $filter['rubrique'] = $request->request->get('rubrique');
                 $filter['dateDebut'] = $request->request->get('dateDebut');
                 $filter['dateFin'] = $request->request->get('dateFin');
                 $listEvent = $em->getRepository('MdyXlagendaBundle:Event')->findFilter($filter);
                 return $this->render('MdyXlagendaBundle:Event:visitor.ajax.twig', array('listEvent' => $listEvent));
             } else {
             }
         } else {
             // il s'agit d'un appel "standard"
             $listEvent = $em->getRepository('MdyXlagendaBundle:Event')->myFindAll();
             $listLieu = $em->getRepository('MdyXlagendaBundle:Lieu')->findAll();
             $listRubrique = $em->getRepository('MdyXlagendaBundle:Rubrique')->findAll();
             return $this->render('MdyXlagendaBundle:Event:visitor.html.twig', array('listEvent' => $listEvent, 'listLieu' => $listLieu, 'listRubrique' => $listRubrique, 'filter' => null));
         }
     }
 }
开发者ID:rthreis,项目名称:GST,代码行数:32,代码来源:EventController.php

示例12: needConsoleInjection

 public function needConsoleInjection(Request $request, Response $response)
 {
     if ($request->isXmlHttpRequest() || !$response->headers->has('X-Debug-Token') || '3' === substr($response->getStatusCode(), 0, 1) || $response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html') || 'html' !== $request->getRequestFormat()) {
         return false;
     }
     return true;
 }
开发者ID:rdalambic,项目名称:web-crystal-palace,代码行数:7,代码来源:ToolbarListener.php

示例13: getRecord

 /**
  * Get record detailed view
  *
  * @param Application $app
  * @param Request     $request
  *
  * @return JsonResponse
  */
 public function getRecord(Application $app, Request $request)
 {
     if (!$request->isXmlHttpRequest()) {
         $app->abort(400);
     }
     $searchEngine = $options = null;
     $train = '';
     if ('' === ($env = strtoupper($request->get('env', '')))) {
         $app->abort(400, '`env` parameter is missing');
     }
     // Use $request->get as HTTP method can be POST or GET
     if ('RESULT' == ($env = strtoupper($request->get('env', '')))) {
         try {
             $options = SearchEngineOptions::hydrate($app, $request->get('options_serial'));
             $searchEngine = $app['phraseanet.SE'];
         } catch (\Exception $e) {
             $app->abort(400, 'Search-engine options are not valid or missing');
         }
     }
     $pos = (int) $request->get('pos', 0);
     $query = $request->get('query', '');
     $reloadTrain = !!$request->get('roll', false);
     $record = new \record_preview($app, $env, $pos < 0 ? 0 : $pos, $request->get('cont', ''), $searchEngine, $query, $options);
     if ($record->is_from_reg()) {
         $train = $app['twig']->render('prod/preview/reg_train.html.twig', ['record' => $record]);
     }
     if ($record->is_from_basket() && $reloadTrain) {
         $train = $app['twig']->render('prod/preview/basket_train.html.twig', ['record' => $record]);
     }
     if ($record->is_from_feed()) {
         $train = $app['twig']->render('prod/preview/feed_train.html.twig', ['record' => $record]);
     }
     return $app->json(["desc" => $app['twig']->render('prod/preview/caption.html.twig', ['record' => $record, 'highlight' => $query, 'searchEngine' => $searchEngine, 'searchOptions' => $options]), "html_preview" => $app['twig']->render('common/preview.html.twig', ['record' => $record]), "others" => $app['twig']->render('prod/preview/appears_in.html.twig', ['parents' => $record->get_grouping_parents(), 'baskets' => $record->get_container_baskets($app['EM'], $app['authentication']->getUser())]), "current" => $train, "history" => $app['twig']->render('prod/preview/short_history.html.twig', ['record' => $record]), "popularity" => $app['twig']->render('prod/preview/popularity.html.twig', ['record' => $record]), "tools" => $app['twig']->render('prod/preview/tools.html.twig', ['record' => $record]), "pos" => $record->get_number(), "title" => str_replace(['[[em]]', '[[/em]]'], ['<em>', '</em>'], $record->get_title($query, $searchEngine))]);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:42,代码来源:Records.php

示例14: listAction

 public function listAction(Request $request)
 {
     $em = $this->getDoctrine()->getManager();
     $objBrowser = new \App\BackendBundle\Utils\Form\Offers\OffersBrowser($request, $this->getUser(), $em);
     $template = $request->isXmlHttpRequest() ? 'AppBackendBundle:Offers:listAjax.html.twig' : 'AppBackendBundle:Offers:list.html.twig';
     return $this->render($template, array('sort_form' => $this->createForm($objBrowser->getSortForm())->createView(), 'filter_form' => $this->createForm($objBrowser->getFilterForm())->createView(), 'browser' => $objBrowser));
 }
开发者ID:jgadek,项目名称:epozyczki,代码行数:7,代码来源:OffersController.php

示例15: getContentType

 /**
  * Gets the normalized type of a request.
  *
  * The normalized type is a short, lowercase version of the format, such as
  * 'html', 'json' or 'atom'.
  *
  * @param \Symfony\Component\HttpFoundation\Request $request
  *   The request object from which to extract the content type.
  *
  * @return string
  *   The normalized type of a given request.
  */
 public function getContentType(Request $request)
 {
     // AJAX iframe uploads need special handling, because they contain a JSON
     // response wrapped in <textarea>.
     if ($request->get('ajax_iframe_upload', FALSE)) {
         return 'iframeupload';
     }
     // Check all formats, if priority format is found return it.
     $first_found_format = FALSE;
     $priority = array('html', 'drupal_ajax', 'drupal_modal', 'drupal_dialog');
     foreach ($request->getAcceptableContentTypes() as $mime_type) {
         $format = $request->getFormat($mime_type);
         if (in_array($format, $priority, TRUE)) {
             return $format;
         }
         if (!is_null($format) && !$first_found_format) {
             $first_found_format = $format;
         }
     }
     // No HTML found, return first found.
     if ($first_found_format) {
         return $first_found_format;
     }
     if ($request->isXmlHttpRequest()) {
         return 'ajax';
     }
     // Do HTML last so that it always wins.
     return 'html';
 }
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:41,代码来源:ContentNegotiation.php


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