當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。