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


PHP GetResponseEvent::stopPropagation方法代码示例

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


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

示例1: handle

 public function handle(GetResponseEvent $event)
 {
     // getting request
     $request = $event->getRequest();
     // getting attributes
     $apiClientToken = $request->attributes->get('apiClientToken');
     $apiUserToken = $request->attributes->get('apiUserToken');
     $apiServerAction = $request->attributes->get('apiAction');
     /* @var $apiServerAction ApiServerAction */
     // cleaning credentials and interface name
     $request->attributes->remove('apiClientToken');
     $request->attributes->remove('apiUserToken');
     // creating token
     $token = new Token($apiServerAction->getApiServerInterface());
     $token->setCredentials([$apiClientToken, $apiUserToken]);
     try {
         // authenticating
         $authenticatedToken = $this->authenticationManager->authenticate($token);
         $this->tokenStorage->setToken($authenticatedToken);
         // getting authenticated user
         $user = $authenticatedToken->getUser();
         /* @var $user User */
         // setting request attributes
         $request->attributes->set('apiConnection', $user->getApiConnection());
         $request->attributes->set('apiClient', $user->getApiClient());
         $request->attributes->set('apiUser', $user->getApiUser());
     } catch (\Exception $e) {
         $event->stopPropagation();
         throw new AccessDeniedHttpException(null, $e);
     }
 }
开发者ID:leoza,项目名称:api-server-bundle,代码行数:31,代码来源:AuthenticationListener.php

示例2: redirectToSsl

 private function redirectToSsl(GetResponseEvent $event)
 {
     $event->stopPropagation();
     $redirect = "https://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
     header("HTTP/1.1 302 Found");
     header("Location: {$redirect}");
     exit;
 }
开发者ID:M03G,项目名称:PrestaShop,代码行数:8,代码来源:SslMiddleware.php

示例3: setNotAcceptableError

 private function setNotAcceptableError(GetResponseEvent $event)
 {
     $responseFactory = new ResponseFactory($this->accept->getDefault());
     $catalogResponse = new \Dafiti\Silex\Response(HttpFoundation\Response::HTTP_NOT_ACCEPTABLE);
     $response = $responseFactory->create($catalogResponse);
     $event->setResponse($response);
     $event->stopPropagation();
 }
开发者ID:dafiti,项目名称:contentnegotiation-service-provider,代码行数:8,代码来源:Header.php

示例4: onMaintenance

 public function onMaintenance(GetResponseEvent $event)
 {
     if ($this->maintenance == true) {
         $content = $this->twig->render('TroiswaFrontBundle:Maintenance:index.html.twig');
         $event->setResponse(new Response($content, 503));
         $event->stopPropagation();
     }
 }
开发者ID:kpmadness,项目名称:symfony3wa,代码行数:8,代码来源:MaintenanceListener.php

示例5: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     $debug = in_array($this->environnement, ['test', 'dev']);
     if ($this->isMaintenance && !$debug) {
         $content = $this->twig->render('TroiswaBackBundle:Maintenance:index.html.twig');
         $event->setResponse(new Response($content, 503));
         $event->stopPropagation();
     }
 }
开发者ID:unpetitlu,项目名称:3wasymfo-1mois,代码行数:9,代码来源:MaintenanceListener.php

示例6: onKernelRequest

 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($request->headers->has('Access-Control-Request-Headers') and $request->headers->has('Access-Control-Request-Method')) {
         $response = new Response();
         $response->headers->add(['Access-Control-Allow-Headers' => $request->headers->get('Access-Control-Request-Headers'), 'Access-Control-Allow-Methods' => $request->headers->get('Access-Control-Request-Method'), 'Access-Control-Allow-Origin' => '*']);
         $event->setResponse($response);
         $event->stopPropagation();
     }
 }
开发者ID:sibers-voronov,项目名称:govwiki-backend,代码行数:13,代码来源:CorsListener.php

示例7: miseEnMaintenance

 public function miseEnMaintenance(GetResponseEvent $event)
 {
     //die(dump($this->maintenance, $this->environnement));
     $contenuHTML = $this->twig->render('TroiswaBackBundle:Other:maintenance.html.twig');
     if ($this->maintenance && $this->environnement == 'prod') {
         $event->setResponse(new Response($contenuHTML, 503));
         // contenu et code maintenance
         $event->stopPropagation();
     }
 }
开发者ID:nickson75,项目名称:Symfony3WA,代码行数:10,代码来源:Maintenance.php

示例8: handle

 public function handle(GetResponseEvent $event)
 {
     try {
         $token = new Token();
         $authenticatedToken = $this->authenticationManager->authenticate($token);
         $this->tokenStorage->setToken($authenticatedToken);
     } catch (\Exception $e) {
         $event->stopPropagation();
         throw new AccessDeniedHttpException(null, $e);
     }
 }
开发者ID:leoza,项目名称:api-client-bundle,代码行数:11,代码来源:AuthenticationListener.php

示例9: miseEnMaintenance

 public function miseEnMaintenance(GetResponseEvent $event)
 {
     //Si je suis en maintenance et qu'on est en environnement de prod
     if ($this->maintenance && $this->environnement == 'prod') {
         $contenuHTML = $this->twig->render('WaBackBundle:Partial:maintenance.html.twig');
         //Par défaut le code respone est 200 on le passe en 503 = maintenance
         $event->setResponse(new Response($contenuHTML, 503));
         // contenu et code maintenance
         $event->stopPropagation();
     }
 }
开发者ID:kh1fry,项目名称:3wasymfony2,代码行数:11,代码来源:Maintenance.php

示例10: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     // Si no es una peticion maestra ignora el evento
     if (!$event->isMasterRequest()) {
         return;
     }
     $request = $event->getRequest();
     $rules = $this->Config->get('security', 'access_control');
     foreach ($rules as $rule) {
         $requestMatcher = new RequestMatcher($rule['pattern']);
         // Si es verdadero es una area restringida
         if ($requestMatcher->matches($request)) {
             // Busca en la session si existe una tarjeta del usuario
             // La tajeta debe ser un objecto de serializado que implemente la interfaz CardInterface
             $user_card = $this->CardManager->getCard('user_card');
             // Si la tarjeta existe
             if ($user_card) {
                 $role = $user_card->getRole();
                 // Si no tiene el rol correcto retorna una respuesta para redireccionar
                 if ($role == null || strtoupper($role) != strtoupper($rule['role'])) {
                     // Detiene la propagacion del evento
                     $event->stopPropagation();
                     if ($request->isXmlHttpRequest()) {
                         $event->setResponse(new JsonResponse(array('status' => 'forbidden')), Response::HTTP_FORBIDDEN);
                     } else {
                         $event->setResponse(new redirectResponse(Util::buildUrl($rule['forbidden_route'])));
                     }
                     return;
                 }
             } else {
                 $event->stopPropagation();
                 if ($request->isXmlHttpRequest()) {
                     $event->setResponse(new JsonResponse(array('status' => 'forbidden')), Response::HTTP_FORBIDDEN);
                 } else {
                     $event->setResponse(new redirectResponse(Util::buildUrl($rule['login_route'])));
                 }
                 return;
             }
         }
     }
 }
开发者ID:kodazzi,项目名称:framework,代码行数:41,代码来源:Firewall.php

示例11: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     $result = $this->securityManager->vote();
     if ($result === SecurityManager::ACCESS_DENIED_DEFER) {
         $event->stopPropagation();
         $redirectUrl = $this->router->generate($this->forceAccountRecovery['route_recover_account']['name'], $this->forceAccountRecovery['route_recover_account']['params']);
         $event->setResponse(new RedirectResponse($redirectUrl));
     }
 }
开发者ID:nvision-luxembourg,项目名称:CCDNUserSecurityBundle,代码行数:12,代码来源:DeferLoginListener.php

示例12: onKernelRequest

 public function onKernelRequest(GetResponseEvent $event)
 {
     $maintenanceUntil = $this->container->hasParameter('underMaintenanceUntil') ? $this->container->getParameter('underMaintenanceUntil') : false;
     $maintenance = $this->container->hasParameter('maintenance') ? $this->container->getParameter('maintenance') : false;
     $debug = in_array($this->container->get('kernel')->getEnvironment(), array('test', 'dev'));
     if ($maintenance && !$debug) {
         $engine = $this->container->get('templating');
         $content = $engine->render('::maintenance.html.twig', array('maintenanceUntil' => $maintenanceUntil));
         $event->setResponse(new Response($content, 503));
         $event->stopPropagation();
     }
 }
开发者ID:thebuggl-org,项目名称:tests-buggl,代码行数:12,代码来源:MaintenanceListener.php

示例13: onKernelRequest

 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($this->installed || $event->getRequestType() !== HttpKernel::MASTER_REQUEST) {
         return;
     }
     $route = $event->getRequest()->get('_route');
     if (!in_array($route, $this->allowRoutes)) {
         $response = new RedirectResponse($this->router->generate(self::INSTALLER_ROUTE));
         $event->setResponse($response);
         $event->stopPropagation();
     }
 }
开发者ID:csbill,项目名称:csbill,代码行数:15,代码来源:RequestListener.php

示例14: onKernelRequest

 /**
  * @param GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() !== HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     /* @var $server ServerBag */
     $server = $event->getRequest()->server;
     // Check that the access to the application by the local computer or local network
     if ($server->get('HTTP_CLIENT_IP') || $server->get('HTTP_X_FORWARDED_FOR') || !($addr = $server->get('REMOTE_ADDR')) || !$this->isLocalHost($addr) && !$this->isLocalNetwork($addr)) {
         $response = new Response('You are not allowed to access this application.', Response::HTTP_FORBIDDEN);
         $event->setResponse($response->setPublic());
         $event->stopPropagation();
     }
 }
开发者ID:anime-db,项目名称:anime-db,代码行数:17,代码来源:Firewall.php

示例15: onRequest

 public function onRequest(GetResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
         return;
     }
     if (!$this->installed) {
         $allowedRoutes = array('oro_installer_flow', 'sylius_flow_display', 'sylius_flow_forward');
         if ($this->debug) {
             $allowedRoutes = array_merge($allowedRoutes, array('_wdt', '_profiler', '_profiler_search', '_profiler_search_bar', '_profiler_search_results', '_profiler_router'));
         }
         if (!in_array($event->getRequest()->get('_route'), $allowedRoutes)) {
             $event->setResponse(new RedirectResponse($event->getRequest()->getBasePath() . '/install.php'));
         }
         $event->stopPropagation();
     } else {
         // allow open the installer even if the application is already installed
         // this is required because we are clearing the cache on the last installation step
         // and as the result the login page is appeared instead of the final installer page
         if ($event->getRequest()->attributes->get('scenarioAlias') === 'oro_installer' && ($event->getRequest()->attributes->get('_route') === 'sylius_flow_forward' || $event->getRequest()->attributes->get('_route') === 'sylius_flow_display')) {
             $event->stopPropagation();
         }
     }
 }
开发者ID:xamin123,项目名称:platform,代码行数:23,代码来源:RequestListener.php


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