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


PHP GetResponseEvent::getResponse方法代码示例

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


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

示例1: it_does_not_secure_when_it_does_not

 public function it_does_not_secure_when_it_does_not(GetResponseEvent $event)
 {
     $event->getRequestType()->willReturn(HttpKernelInterface::MASTER_REQUEST);
     $event->getRequest()->willReturn($this->unsecureRequest);
     $event->getResponse()->shouldNotBeCalled();
     $this->onKernelRequest($event);
 }
开发者ID:AbdoulNdiaye,项目名称:DunglasAngularCsrfBundle,代码行数:7,代码来源:AngularCsrfValidationListenerSpec.php

示例2: getResponse

 /**
  * @param GetResponseEvent $event
  * @param Request          $request
  * @param RpcRequest       $rpcRequest
  *
  * @return Response
  */
 protected function getResponse(GetResponseEvent $event, Request $request, RpcRequest $rpcRequest = null)
 {
     $response = $event->getResponse() ?: new Response();
     $accept = $request->headers->get('Accept');
     $response->headers->set('Content-Type', $accept);
     return $response;
 }
开发者ID:mihai-stancu,项目名称:rpc-bundle,代码行数:14,代码来源:ResponseListener.php

示例3: testOnKernelRequestUserHash

 public function testOnKernelRequestUserHash()
 {
     $hash = '123abc';
     $this->hashGenerator->expects($this->once())->method('generate')->will($this->returnValue($hash));
     $this->request->headers->add(array('X-HTTP-Override' => 'AUTHENTICATE', 'Accept' => Kernel::USER_HASH_ACCEPT_HEADER));
     $this->request->expects($this->once())->method('hasSession')->will($this->returnValue(true));
     $this->assertNull($this->requestEventListener->onKernelRequestUserHash($this->event));
     $this->assertTrue($this->event->isPropagationStopped());
     $this->assertTrue($this->event->hasResponse());
     $response = $this->event->getResponse();
     $this->assertInstanceOf('Symfony\\Component\\HttpFoundation\\Response', $response);
     $this->assertTrue($response->headers->has('X-User-Hash'));
     $this->assertSame($hash, $response->headers->get('X-User-Hash'));
 }
开发者ID:masev,项目名称:ezpublish-kernel,代码行数:14,代码来源:RequestEventListenerTest.php

示例4: checkForHttp

 public function checkForHttp(GetResponseEvent $event)
 {
     $response = $event->getResponse();
     $current_path = \Drupal::service('path.current')->getPath();
     // Special path for verifying SSL status.
     if ($current_path == 'admin/config/system/securepages/test') {
         if (\Drupal::request()->isSecure()) {
             // @TODO: Update
             //header('HTTP/1.1 200 OK');
             $response->setStatusCode('200');
             $response->send();
         } else {
             // @TODO: Update
             //header('HTTP/1.1 404 Not Found');
             $response->setStatusCode('404');
             $response->send();
         }
     }
     $config = \Drupal::config('securepages.settings');
     $securepages_enable = $config->get('securepages_enable');
     if ($securepages_enable && basename($_SERVER['PHP_SELF']) == 'index.php' && php_sapi_name() != 'cli') {
         $securepagesservice = \Drupal::service('securepages.securepagesservice');
         $redirect = $securepagesservice->securePagesRedirect();
         if (is_null($redirect)) {
         } elseif ($redirect == TRUE) {
             $url = Url::fromUri($event->getRequest()->getUri(), array('absolute' => TRUE, 'https' => TRUE))->toString();
             $event->setResponse(new RedirectResponse($url, 302));
         } elseif ($redirect == FALSE) {
             $url = Url::fromUri($event->getRequest()->getUri(), array('absolute' => TRUE, 'https' => FALSE))->toString();
             $event->setResponse(new RedirectResponse($url, 302));
         }
         // Store the response in the page cache.
         // @TODO: port this code
         /*
                 if (variable_get('cache', 0) && ($cache = drupal_page_set_cache())) {
                   drupal_serve_page_from_cache($cache);
                 }
                 else {
                   ob_flush();
                 }
         */
         //}
     }
 }
开发者ID:jstephendix,项目名称:securepages,代码行数:44,代码来源:SecurePagesEventSubscriber.php

示例5: onKernelRequestSiteOff

 public function onKernelRequestSiteOff(GetResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     $response = $event->getResponse();
     $request = $event->getRequest();
     if ($response instanceof PlainResponse || $response instanceof JsonResponse || $request->isXmlHttpRequest()) {
         return;
     }
     if (\System::isInstalling()) {
         return;
     }
     // Get variables
     $module = strtolower($request->query->get('module'));
     $type = strtolower($request->query->get('type'));
     $func = strtolower($request->query->get('func'));
     $siteOff = (bool) \System::getVar('siteoff');
     $hasAdminPerms = \SecurityUtil::checkPermission('ZikulaSettingsModule::', 'SiteOff::', ACCESS_ADMIN);
     $urlParams = $module == 'users' && $type == 'user' && $func == 'siteofflogin';
     // params are lowercase
     $versionCheck = \Zikula_Core::VERSION_NUM != \System::getVar('Version_Num');
     // Check for site closed
     if ($siteOff && !$hasAdminPerms && !$urlParams || $versionCheck) {
         $hasOnlyOverviewAccess = \SecurityUtil::checkPermission('ZikulaUsersModule::', '::', ACCESS_OVERVIEW);
         if ($hasOnlyOverviewAccess && \UserUtil::isLoggedIn()) {
             \UserUtil::logout();
         }
         // initialise the language system to enable translations (#1764)
         $lang = \ZLanguage::getInstance();
         $lang->setup($request);
         $response = new Response();
         $response->headers->add(array('HTTP/1.1 503 Service Unavailable'));
         $response->setStatusCode(503);
         $content = (require_once \System::getSystemErrorTemplate('siteoff.tpl'));
         // move to CoreBundle and use Twig
         $response->setContent($content);
         $event->setResponse($response);
         $event->stopPropagation();
     }
 }
开发者ID:rmaiwald,项目名称:core,代码行数:41,代码来源:SiteOffListener.php

示例6: checkForHttp

 public function checkForHttp(GetResponseEvent $event)
 {
     $response = $event->getResponse();
     $current_path = \Drupal::service('path.current')->getPath();
     $config = \Drupal::config('securepages.settings');
     $securepages_enable = $config->get('securepages_enable');
     if ($securepages_enable && basename($_SERVER['PHP_SELF']) == 'index.php' && php_sapi_name() != 'cli') {
         $securepagesservice = \Drupal::service('securepages.securepagesservice');
         $redirect = $securepagesservice->securePagesRedirect();
         $request = $event->getRequest();
         //Replaces current URL with the one defined in the module's settings page.
         $uri = $securepagesservice->securePagesGenerateUrl($request->getSchemeAndHttpHost(), $request->getUri(), $redirect);
         if (is_null($redirect)) {
         } elseif ($redirect == TRUE) {
             //Unset destination parameter so this won't redirect in this request
             $request->query->remove('destination');
             $url = Url::fromUri($uri, array('absolute' => TRUE, 'https' => TRUE))->toString();
             $event->setResponse(new TrustedRedirectResponse($url, 302));
         } elseif ($redirect == FALSE) {
             //If parameter "destination" is set, don't force redirect to HTTP.
             //This prevents a loop when the user is logged in without SSL and then needs to login with SSL.
             if (!empty($request->query->get('destination'))) {
                 return;
             }
             $url = Url::fromUri($uri, array('absolute' => TRUE, 'https' => FALSE))->toString();
             $event->setResponse(new TrustedRedirectResponse($url, 302));
         }
         // Store the response in the page cache.
         // @TODO: port this code
         /*
                 if (variable_get('cache', 0) && ($cache = drupal_page_set_cache())) {
                   drupal_serve_page_from_cache($cache);
                 }
                 else {
                   ob_flush();
                 }
         */
         //}
     }
 }
开发者ID:badjava,项目名称:securepages,代码行数:40,代码来源:SecurePagesEventSubscriber.php

示例7: onKernelRequest

 /**
  * @param GetResponseEvent $event
  * @return bool
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     //Check if we have to prerender page
     $request = $event->getRequest();
     if (!$this->shouldPrerenderPage($request)) {
         return false;
     }
     $event->stopPropagation();
     //Dispatch event for a more custom way of retrieving response
     $eventBefore = new RenderBeforeEvent($request);
     // @codingStandardsIgnoreStart
     $this->eventDispatcher->dispatch(Events::onBeforeRequest, $eventBefore);
     // @codingStandardsIgnoreEnd
     //Check if event get back a response
     if ($eventBefore->hasResponse()) {
         $response = $eventBefore->getResponse();
         if (is_string($response)) {
             $event->setResponse(new Response($response, 200));
             return true;
         } elseif ($response instanceof Response) {
             $event->setResponse($response);
             return true;
         }
     }
     //Launch prerender
     if ($this->forceSecureRedirect === null) {
         $scheme = $request->getScheme();
     } else {
         $scheme = $this->forceSecureRedirect ? 'https' : 'http';
     }
     $uri = rtrim($this->backendUrl, '/') . '/' . $scheme . '://' . $request->getHost() . $request->getRequestUri();
     try {
         $event->setResponse(new Response($this->httpClient->send($uri), 200));
     } catch (\Yucca\PrerenderBundle\HttpClient\Exception $e) {
         // pass
     }
     //Dispatch event to save response
     if ($event->getResponse()) {
         $eventAfter = new RenderAfterEvent($request, $event->getResponse());
         // @codingStandardsIgnoreStart
         $this->eventDispatcher->dispatch(Events::onAfterRequest, $eventAfter);
         // @codingStandardsIgnoreEnd
     }
     return true;
 }
开发者ID:nick4fake,项目名称:YuccaPrerenderBundle,代码行数:49,代码来源:KernelListener.php


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