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


PHP GetResponseEvent::getRequestType方法代码示例

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


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

示例1: onKernelRequest

 /**
  * If users flag isFirstLogin is true redirect to change password page.
  *
  * @param \Symfony\Component\HttpKernel\Event\FilterResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     // Don't do anything if it's not the master request or another firewall than "secured"
     $isSecuredArea = (bool) preg_match('/^\\/secured/', $event->getRequest()->getPathInfo());
     if (HttpKernel::MASTER_REQUEST != $event->getRequestType() || !$isSecuredArea) {
         return;
     }
     $token = $this->tokenStorage->getToken();
     $user = $token->getUser();
     // check if employee object exists
     if (is_object($user) && null !== $user->getEmployee()) {
         $today = new \DateTime('today');
         $isInactive = (bool) (null !== $user->getEmployee()->getLeavingDate() && $user->getEmployee()->getLeavingDate() < $today);
         // Update user object if leaving date is passed and user is still active
         if ($token->getUser()->getIsActive() && $isInactive) {
             $user->setIsActive(false);
             $this->entityManager->persist($user);
             $this->entityManager->flush();
             if (null !== $this->logger) {
                 $this->logger->notice('[InactiveUserListener] Employee passed leaving date, user will be disabled.', array('username' => $user->getUsername()));
             }
             // TODO: Return a proper error message on the login page
             $logoutUrl = $this->router->generate('OpitOpitHrmUserBundle_logout', array(), true);
             $event->setResponse(new RedirectResponse($logoutUrl));
         }
     }
 }
开发者ID:hkmshb,项目名称:OpitHrm,代码行数:32,代码来源:InactiveUserListener.php

示例2: onKernelRequest

 /**
  * Action performed on kernel response event.
  *
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event The response event.
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     $event->getRequest()->server->set('REMOTE_ADDR', $this->fakeIp);
 }
开发者ID:olegfod,项目名称:IvoryGoogleMapBundle,代码行数:12,代码来源:FakeRequestListener.php

示例3: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
         // don't do anything if it's not the master request
         return;
     }
     $token = $this->context->getToken();
     if (is_null($token)) {
         return;
     }
     $_route = $event->getRequest()->attributes->get('_route');
     if ($this->context->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
         if (!$token->getUser() instanceof PersonInterface) {
             // We don't have a PersonInterface... Nothing to do here.
             return;
         }
         if ($_route == 'lc_home' || $_route == 'fos_user_security_login') {
             $key = '_security.main.target_path';
             #where "main" is your firewall name
             //check if the referer session key has been set
             if ($this->session->has($key)) {
                 //set the url based on the link they were trying to access before being authenticated
                 $url = $this->session->get($key);
                 //remove the session key
                 $this->session->remove($key);
             } else {
                 $url = $this->router->generate('lc_dashboard');
             }
             $event->setResponse(new RedirectResponse($url));
         } else {
             $this->checkUnconfirmedEmail();
         }
     }
 }
开发者ID:hacklabr,项目名称:login-cidadao,代码行数:34,代码来源:LoggedInUserListener.php

示例4: onRequest

 /**
  * @param GetResponseEvent $event
  */
 public function onRequest(GetResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
         return;
     }
     $this->requestLogger->logRequest($event->getRequest());
 }
开发者ID:Hexanet,项目名称:MonologExtraBundle,代码行数:10,代码来源:RequestResponseListener.php

示例5: onKernelRequest

 /**
  * Determines and sets the Request format.
  *
  * @param GetResponseEvent $event The event
  *
  * @throws NotAcceptableHttpException
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if (!$request->attributes->get(FOSRestBundle::ZONE_ATTRIBUTE, true)) {
         return;
     }
     try {
         $format = $request->getRequestFormat(null);
         if (null === $format) {
             $accept = $this->formatNegotiator->getBest('');
             if (null !== $accept && 0.0 < $accept->getQuality()) {
                 $format = $request->getFormat($accept->getType());
                 if (null !== $format) {
                     $request->attributes->set('media_type', $accept->getValue());
                 }
             }
         }
         if (null === $format) {
             if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
                 throw new NotAcceptableHttpException('No matching accepted Response format could be determined');
             }
             return;
         }
         $request->setRequestFormat($format);
     } catch (StopFormatListenerException $e) {
         // nothing to do
     }
 }
开发者ID:patxi1980,项目名称:FOSRestBundle,代码行数:35,代码来源:FormatListener.php

示例6: fetchRequest

 /**
  * @param GetResponseEvent $event
  */
 public function fetchRequest(GetResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     $this->request = $event->getRequest();
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:10,代码来源:ResourceExtension.php

示例7: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($event->getRequestType() == HttpKernelInterface::MASTER_REQUEST && $request->getMethod() == 'POST') {
         if (stripos($request->getPathInfo(), '/mapi') === 0) {
             return;
         }
         if (stripos($request->getPathInfo(), '/hls') === 0) {
             return;
         }
         $whiteList = array('/coin/pay/return/alipay', '/coin/pay/notify/alipay', '/coin/pay/notify/wxpay', '/pay/center/pay/alipay/return', '/pay/center/pay/wxpay/notify', '/pay/center/pay/alipay/notify', '/live/verify', '/course/order/pay/alipay/notify', '/vip/pay_notify/alipay', '/uploadfile/upload', '/uploadfile/cloud_convertcallback', '/uploadfile/cloud_convertcallback2', '/uploadfile/cloud_convertcallback3', '/uploadfile/cloud_convertheadleadercallback', '/disk/upload', '/file/upload', '/editor/upload', '/disk/convert/callback', '/partner/phpwind/api/notify', '/partner/discuz/api/notify', '/live/auth', '/edu_cloud/sms_callback');
         if (in_array($request->getPathInfo(), $whiteList)) {
             return;
         }
         if ($request->isXmlHttpRequest()) {
             $token = $request->headers->get('X-CSRF-Token');
         } else {
             $token = $request->request->get('_csrf_token', '');
         }
         $request->request->remove('_csrf_token');
         $expectedToken = $this->container->get('form.csrf_provider')->generateCsrfToken('site');
         if ($token != $expectedToken) {
             // @todo 需要区分ajax的response
             if ($request->getPathInfo() == '/admin') {
                 $token = $request->request->get('token');
                 $result = ServiceKernel::instance()->createService('CloudPlatform.AppService')->repairProblem($token);
                 $this->container->set('Topxia.RepairProblem', $result);
             } else {
                 $response = $this->container->get('templating')->renderResponse('TopxiaWebBundle:Default:message.html.twig', array('type' => 'error', 'message' => '页面已过期,请重新提交数据!', 'goto' => '', 'duration' => 0));
                 $event->setResponse($response);
             }
         }
     }
 }
开发者ID:ccq18,项目名称:EduSoho,代码行数:34,代码来源:KernelRequestListener.php

示例8: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     // If we have a somebody elses controller, just exit (for now)
     $controller = $request->attributes->get('_controller');
     if (false === strpos($controller, 'ZenMagick')) {
         return;
     }
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     $dispatcher = $event->getDispatcher();
     $request->getSession()->restorePersistedServices();
     $dispatcher->dispatch('request_ready', new GenericEvent($this, array('request' => $request)));
     $dispatcher->dispatch('container_ready', new GenericEvent($this, array('request' => $request)));
     $this->container->get('sacsManager')->authorize($request, $request->getRequestId(), $request->getAccount());
     foreach ($this->container->get('containerTagService')->findTaggedServiceIds('zenmagick.http.session.validator') as $id => $args) {
         if (null != ($validator = $this->container->get($id)) && $validator instanceof SessionValidator) {
             $session = $request->getSession();
             if (!$validator->isValidSession($request, $session)) {
                 $session->getFlashBag()->error('Invalid session');
                 $session->migrate();
                 $event->setResponse(new RedirectResponse($request->server->get('HTTP_REFERER')));
             }
         }
     }
 }
开发者ID:zenmagick,项目名称:zenmagick,代码行数:27,代码来源:HttpListener.php

示例9: onKernelRequest

 /**
  * Determines and sets the Request format
  *
  * @param GetResponseEvent $event The event
  *
  * @throws NotAcceptableHttpException
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     try {
         $request = $event->getRequest();
         $format = $request->getRequestFormat(null);
         if (null === $format) {
             if ($this->formatNegotiator instanceof MediaTypeNegotiatorInterface) {
                 $mediaType = $this->formatNegotiator->getBestMediaType($request);
                 if ($mediaType) {
                     $request->attributes->set('media_type', $mediaType);
                     $format = $request->getFormat($mediaType);
                 }
             } else {
                 $format = $this->formatNegotiator->getBestFormat($request);
             }
         }
         if (null === $format) {
             if ($event->getRequestType() === HttpKernelInterface::MASTER_REQUEST) {
                 throw new NotAcceptableHttpException("No matching accepted Response format could be determined");
             }
             return;
         }
         $request->setRequestFormat($format);
     } catch (StopFormatListenerException $e) {
         // nothing to do
     }
 }
开发者ID:mgldev,项目名称:coffeetrack,代码行数:34,代码来源:FormatListener.php

示例10: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     if (!$this->app['phraseanet.configuration']['api_cors']['enabled']) {
         return;
     }
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     $request = $event->getRequest();
     if (!preg_match('{api/v(\\d+)}i', $request->getPathInfo() ?: '/')) {
         return;
     }
     // skip if not a CORS request
     if (!$request->headers->has('Origin') || $request->headers->get('Origin') == $request->getSchemeAndHttpHost()) {
         return;
     }
     $options = array_merge(['allow_credentials' => false, 'allow_origin' => [], 'allow_headers' => [], 'allow_methods' => [], 'expose_headers' => [], 'max_age' => 0, 'hosts' => []], $this->app['phraseanet.configuration']['api_cors']);
     // skip if the host is not matching
     if (!$this->checkHost($request, $options)) {
         return;
     }
     // perform preflight checks
     if ('OPTIONS' === $request->getMethod()) {
         $event->setResponse($this->getPreflightResponse($request, $options));
         return;
     }
     if (!$this->checkOrigin($request, $options)) {
         $response = new Response('', 403, ['Access-Control-Allow-Origin' => 'null']);
         $event->setResponse($response);
         return;
     }
     $this->app['dispatcher']->addListener(KernelEvents::RESPONSE, [$this, 'onKernelResponse']);
     $this->options = $options;
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:34,代码来源:ApiCorsSubscriber.php

示例11: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event, $eventName, EventDispatcherInterface $dispatcher)
 {
     if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
         // don't do anything if it's not the master request
         return;
     }
     $token = $this->tokenStorage->getToken();
     if (is_null($token) || $token instanceof OAuthToken || $this->authChecker->isGranted('IS_AUTHENTICATED_REMEMBERED') === false) {
         return;
     }
     if (!$token->getUser() instanceof PersonInterface) {
         // We don't have a PersonInterface... Nothing to do here.
         return;
     }
     try {
         $this->handleTargetPath($event);
         $tasks = $this->checkTasks($event, $dispatcher);
         if (!$tasks) {
             $this->checkIntent($event);
         }
         $this->checkUnconfirmedEmail();
     } catch (RedirectResponseException $e) {
         $event->setResponse($e->getResponse());
     }
 }
开发者ID:redelivre,项目名称:login-cidadao,代码行数:25,代码来源:LoggedInUserListener.php

示例12: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     $request = $event->getRequest();
     $fc_form = $this->form_service->guessFcForm($request);
     if (!$fc_form instanceof FcForm) {
         return;
     }
     if ($fc_form->getAction()) {
         return;
     }
     /** @var FormInterface $form */
     $form = $this->form_service->create($fc_form);
     $form->handleRequest($request);
     if ($form->isValid()) {
         $data = $form->getData();
         $this->form_service->clear($fc_form, array('template' => $data['_template'], 'data' => $this->form_service->initData($data)));
         if ($fc_form->getIsAjax()) {
             return;
         }
         if ($fc_form->getMessage()) {
             $message = $fc_form->getMessage();
         } else {
             $message = $this->translator->trans('fc.message.form.is_valid', array(), 'FenrizbesFormConstructorBundle');
         }
         // TODO: Связывать сообщение с конкретной формой и подчищать старые
         $this->session->getFlashBag()->add('fc_form.success', $message);
         $response = new RedirectResponse($this->router->generate($request->get('_route'), $request->get('_route_params')));
         $event->setResponse($response);
     }
 }
开发者ID:it-blaster,项目名称:form-constructor-bundle,代码行数:33,代码来源:RequestListener.php

示例13: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     $request = $event->getRequest();
     // skip if not a CORS request
     if (!$request->headers->has('Origin') || $request->headers->get('Origin') == $request->getSchemeAndHttpHost()) {
         return;
     }
     $options = [];
     $options['allow_credentials'] = true;
     $options['allow_headers'] = true;
     $options['allow_origin'] = true;
     $options['allow_methods'] = $this->getRouteAllowMethods($request);
     // perform preflight checks
     if ('OPTIONS' === $request->getMethod()) {
         //$options = array();
         $event->setResponse($this->getPreflightResponse($request, $options));
         return;
     }
     if (!$this->checkOrigin($request, $options)) {
         return;
     }
     $this->dispatcher->addListener('kernel.response', [$this, 'onKernelResponse']);
     $this->options = $options;
 }
开发者ID:easylo,项目名称:RESTCorsBundle,代码行数:27,代码来源:CorsListener.php

示例14: onCoreRequest

 /**
  * Start the profiler if
  * - this is not a sub-request but the master request
  * - we are not on the _wdt or _profiler url
  * - if the query argument name is configured, only if it is present in the request
  * - if the url does not match one of the exclude patterns
  *
  * @param GetResponseEvent $event
  */
 public function onCoreRequest(GetResponseEvent $event)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     $request = $event->getRequest();
     $requestQueryArgument = $this->container->getParameter('mjr_library_profiler.request_query_argument');
     if ($requestQueryArgument && is_null($request->query->get($requestQueryArgument))) {
         return;
     } elseif ($requestQueryArgument) {
         $request->query->remove($requestQueryArgument);
     }
     $uri = $request->getRequestUri();
     if (false !== strpos($uri, "_wdt") || false !== strpos($uri, "_profiler")) {
         return;
     }
     if ($excludePatterns = $this->container->getParameter('mjr_library_profiler.exclude_patterns')) {
         foreach ($excludePatterns as $exclude) {
             if (preg_match('@' . $exclude . '@', $uri)) {
                 return;
             }
         }
     }
     $this->collector->startProfiling($request);
 }
开发者ID:ChrisWesterfield,项目名称:MJR.ONE-CP,代码行数:34,代码来源:RequestListener.php

示例15: onKernelRequest

 /**
  * Add the csv format
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST !== $event->getRequestType()) {
         return;
     }
     $event->getRequest()->setFormat('csv', 'text/csv');
 }
开发者ID:javiersantos,项目名称:pim-community-dev,代码行数:11,代码来源:RequestListener.php


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