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


PHP FilterResponseEvent::getRequest方法代码示例

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


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

示例1: onKernelResponse

 public function onKernelResponse(FilterResponseEvent $event)
 {
     $response = $event->getResponse();
     if (null !== $response && $response instanceof PluginResponseInterface) {
         //when a route from a plugin is hit
         if (!$event->getRequest()->attributes->get('_jarves_is_plugin')) {
             //we accept only plugin routes.
             return;
         }
         $pageResponse = $this->pageStack->getPageResponse();
         /** @var $content Content */
         $content = $event->getRequest()->attributes->get('_content');
         //this is later used in ContentTypes\TypePlugin, so it won't execute
         //the same plugin again.
         $pageResponse->setPluginResponse($content->getId(), $response);
         if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType()) {
             //when this was a master request, we need to render the actual content of the page,
             //so HttpKernel can return a valid ready rendered response
             //if a plugin route has been successfully requested
             //we need to handle also the Jarves editor
             if ($this->editMode->isEditMode()) {
                 $this->editMode->registerEditor();
             }
             $pageResponse->renderContent();
         }
         //maintain the actual PageResponse
         $event->setResponse($pageResponse);
     }
 }
开发者ID:jarves,项目名称:jarves,代码行数:29,代码来源:PluginResponseListener.php

示例2: onKernelResponse

 public function onKernelResponse(FilterResponseEvent $event)
 {
     $controller = $event->getRequest()->attributes->get('_controller');
     if (empty($controller)) {
         return;
     }
     if (strpos($controller, '::') !== false) {
         $controller = explode('::', $controller, 2);
         $class = new \ReflectionClass($controller[0]);
         $method = $class->getMethod($controller[1]);
         $annotation = $this->reader->getMethodAnnotation($method, 'PSX\\PSXBundle\\Configuration\\Outgoing');
         $response = $event->getResponse();
         $writer = $this->getWriter($event->getRequest());
         if ($response instanceof DataResponse) {
             if ($annotation instanceof Outgoing) {
                 $file = $this->rootDir . '/' . $annotation->getFile();
                 $data = $this->assimilator->assimilate(JsonSchema::fromFile($file), $response->getData());
                 $response->headers->set('Content-Type', $writer->getContentType());
                 $response->setContent($writer->write($data));
             } else {
                 $data = $this->normalizeData($response->getData());
                 $response->headers->set('Content-Type', $writer->getContentType());
                 $response->setContent($writer->write($data));
             }
         } else {
             throw new RuntimeException('Can only transform responses of PSX\\PSXBundle\\DataResponse');
         }
     }
 }
开发者ID:k42b3,项目名称:psx-bundle,代码行数:29,代码来源:OutgoingListener.php

示例3: onResponseLoad

 /**
  * @param FilterResponseEvent $event
  */
 public function onResponseLoad(FilterResponseEvent $event)
 {
     if (!$event->getRequest()->attributes->has('AJAX_PROCESSING')) {
         return;
     }
     $event->setResponse(new Response($this->adapter->getResponse($event->getRequest()->attributes->get('ajax_commands'))));
 }
开发者ID:itkg,项目名称:core,代码行数:10,代码来源:AjaxRenderResponseListener.php

示例4: onRespond

 /**
  * Redirects login attempts on already-logged-in session to the destination.
  */
 public function onRespond(FilterResponseEvent $event)
 {
     // Return early in most cases.
     if ($event->getRequest()->getMethod() !== 'POST') {
         return;
     }
     if (!$this->currentUser->isAuthenticated()) {
         return;
     }
     if (!$event->isMasterRequest()) {
         return;
     }
     if (!$event->getRequest()->query->has('destination')) {
         return;
     }
     if ($event->getResponse() instanceof RedirectResponse) {
         return;
     }
     // There has to be a better way to figure out if we landed on the 403/404 page.
     $page_403 = $this->configFactory->get('system.site')->get('page.403');
     $page_404 = $this->configFactory->get('system.site')->get('page.404');
     $path = $this->currentPath->getPath();
     $route = $this->currentRouteMatch->getRouteName();
     if ($route == 'system.403' || $page_403 && $path == $page_403 || $route == 'system.404' || $page_404 && $path == $page_404) {
         // RedirectResponseSubscriber will convert to absolute URL for us.
         $event->setResponse(new RedirectResponse($this->redirectDestination->get(), RedirectResponse::HTTP_SEE_OTHER));
     }
 }
开发者ID:Wylbur,项目名称:gj,代码行数:31,代码来源:SecureLoginResponseSubscriber.php

示例5: onKernelResponse

 /**
  * Handles the onKernelResponse event.
  *
  * @param FilterResponseEvent $event A FilterResponseEvent instance
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     $master = HttpKernelInterface::MASTER_REQUEST === $event->getRequestType();
     if ($this->onlyMasterRequests && !$master) {
         return;
     }
     if ($this->onlyException && null === $this->exception) {
         return;
     }
     $exception = $this->exception;
     $this->exception = null;
     if (null !== $this->matcher && !$this->matcher->matches($event->getRequest())) {
         return;
     }
     if ($profile = $this->profiler->collect($event->getRequest(), $event->getResponse(), $exception)) {
         if ($master) {
             $this->profiler->saveProfile($profile);
             foreach ($this->children as $child) {
                 $child->setParent($profile);
                 $this->profiler->saveProfile($child);
             }
             $this->children = array();
         } else {
             $this->children[] = $profile;
         }
     }
 }
开发者ID:robertowest,项目名称:CuteFlow-V4,代码行数:32,代码来源:ProfilerListener.php

示例6: onKernelResponse

 /**
  * 输出debugBar,只有当页面有</body>标签时有效。
  *
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     $response = $event->getResponse();
     $request = $event->getRequest();
     if (!$event->isMasterRequest()) {
         return;
     }
     if ($request->isXmlHttpRequest()) {
         return;
     }
     if ($response->isRedirection() || $response->headers->has('Content-Type') && false === strpos($response->headers->get('Content-Type'), 'html') || 'html' !== $request->getRequestFormat()) {
         return;
     }
     $path = null;
     if ($this->app['debug_bar.auto_res']) {
         $scriptName = $event->getRequest()->server->get('SCRIPT_NAME');
         $path = $scriptName . $this->app['debug_bar.path'];
     } else {
         $path = $this->app['debug_bar.path'];
     }
     $render = $this->app['debug_bar']->getJavascriptRenderer($path);
     ob_start();
     echo $render->renderHead();
     echo $render->render();
     $debugContent = ob_get_contents();
     ob_end_clean();
     $content = $response->getContent();
     if (false === strpos($content, '</body>')) {
         $content .= $debugContent;
     } else {
         $content = str_replace("</body>", $debugContent . '</body>', $content);
     }
     $event->getResponse()->setContent($content);
 }
开发者ID:h2lsoft,项目名称:silex-debugbar,代码行数:39,代码来源:DebugBarServiceProvider.php

示例7: onKernelResponse

 /**
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     $allowedMethods = $this->loader->getAllowedMethods();
     if (isset($allowedMethods[$event->getRequest()->get('_route')])) {
         $event->getResponse()->headers->set('Allow', implode(', ', $allowedMethods[$event->getRequest()->get('_route')]));
     }
 }
开发者ID:kasobus,项目名称:EDENS-Mautic,代码行数:10,代码来源:AllowedMethodsListener.php

示例8: replaceMarkup

 /**
  * Parses content of response and set the replaced html as new content.
  *
  * @param FilterResponseEvent $event
  */
 public function replaceMarkup(FilterResponseEvent $event)
 {
     $format = $event->getRequest()->getRequestFormat(null);
     if (!array_key_exists($format, $this->markupParser)) {
         return;
     }
     $response = $event->getResponse();
     $response->setContent($this->markupParser[$format]->parse($response->getContent(), $event->getRequest()->getLocale()));
 }
开发者ID:sulu,项目名称:sulu,代码行数:14,代码来源:MarkupListener.php

示例9: onKernelResponse

 /**
  * kernel.responseイベント
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     // kernel.responseイベント発生時に出力フォーマットを判定し、
     // csvであればContent-Dispositionヘッダを追加、かつ、レスポンスボディをSJIS-winに変換する
     if ($event->getRequest()->getRequestFormat() === 'csv') {
         $response = $event->getResponse();
         $response->setContent(mb_convert_encoding($response->getContent(), 'SJIS-win', mb_internal_encoding()));
         $response->headers->set('Content-Disposition', sprintf('attachment; filename=%s.csv', $event->getRequest()->get('_filename')));
     }
 }
开发者ID:iwatea,项目名称:Swim,代码行数:13,代码来源:ResponseListener.php

示例10: isEnabled

 /**
  * Check if snippets are allowed for this request.
  *
  * @param FilterResponseEvent $event
  */
 protected function isEnabled(FilterResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return false;
     }
     if (Zone::isFrontend($event->getRequest())) {
         return true;
     }
     return $event->getRequest()->attributes->get('allow_snippets', false);
 }
开发者ID:Johardmeier,项目名称:bolt,代码行数:15,代码来源:SnippetListener.php

示例11: onKernelResponse

 /**
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     $request = $event->getRequest();
     if (!$request->attributes->get(FOSRestBundle::ZONE_ATTRIBUTE, true)) {
         return;
     }
     $allowedMethods = $this->loader->getAllowedMethods();
     if (isset($allowedMethods[$event->getRequest()->get('_route')])) {
         $event->getResponse()->headers->set('Allow', implode(', ', $allowedMethods[$event->getRequest()->get('_route')]));
     }
 }
开发者ID:patxi1980,项目名称:FOSRestBundle,代码行数:14,代码来源:AllowedMethodsListener.php

示例12: addRobotTags

 /**
  * Add resolved tags to X-Robots-Tag response header.
  *
  * @param FilterResponseEvent $event
  */
 public function addRobotTags(FilterResponseEvent $event)
 {
     if (!$event->isMasterRequest()) {
         return;
     }
     if ($this->cloak && !$this->requestChecker->isCrawler($event->getRequest())) {
         return;
     }
     if ($tags = $this->tagResolver->resolve($event->getRequest())) {
         $event->getResponse()->headers->set('X-Robots-Tag', implode(', ', $tags));
     }
 }
开发者ID:cdaguerre,项目名称:robots-bundle,代码行数:17,代码来源:KernelResponseListener.php

示例13: onKernelResponse

    public function onKernelResponse(FilterResponseEvent $event)
    {
        $response = $event->getResponse();
        $request = $event->getRequest();
        // exclude render tags in the WDT and Profiler
        $controller = $request->attributes->get('_controller');
        if ($controller && 'WebProfilerBundle' === substr($controller, 0, 17)) {
            return;
        }
        // do not highlight master responses that are not HTML based
        $contentType = $response->headers->get('Content-Type');
        if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType() && $contentType && !preg_match('{^(text/html|application/xhtml+xml)\\b}', $contentType)) {
            return;
        }
        // skip non-cacheable responses
        if (!$response->isCacheable()) {
            return;
        }
        $response->setContent(sprintf('
                <div class="esi-debug">
                    <div class="esi-debug-details">
                       ESI: %s, Rendered: %s, Cache-Control: %s
                    </div>
                    %s
                </div>

                <style>
                    .esi-debug {
                        border: 1px solid red;
                    }

                    .esi-debug-details {
                        background: red;
                        position: absolute;
                        color: white;
                    }

                    .esi-debug:hover {
                        background: rgba(255, 0, 0, .25);
                        border-color #CC0000;
                        cursor: pointer;
                    }

                    .esi-debug:hover .esi-debug-details {
                        background: #CC0000;
                        z-index: 9999;
                    }
                </style>
            ', $event->getRequest()->getRequestUri(), date('Y-m-d H:i:s'), $response->headers->get('cache-control'), $response->getContent()));
    }
开发者ID:nelmio,项目名称:NelmioEsiDebugBundle,代码行数:50,代码来源:Kernel.php

示例14: onResponse

 /**
  * This method is executed on kernel.response event
  *
  * @param FilterResponseEvent $event
  *
  * @see {http://symfony.com/doc/current/components/http_kernel/introduction.html#the-kernel-response-event}
  */
 public function onResponse(FilterResponseEvent $event)
 {
     $request = $event->getRequest();
     if ($request->attributes->get('response_source') === 'cache') {
         //Prevents re-caching response from cache
         $event->stopPropagation();
         return;
     }
     if (!$event->isMasterRequest()) {
         return;
         //Caching should only occur on master requests, see https://github.com/kiler129/SupercacheBundle/issues/10
     }
     $this->responseHandler->cacheResponse($event->getRequest(), $event->getResponse());
 }
开发者ID:kiler129,项目名称:SupercacheBundle,代码行数:21,代码来源:KernelListener.php

示例15: onKernelResponse

 public function onKernelResponse(FilterResponseEvent $event)
 {
     if (HttpKernel::MASTER_REQUEST != $event->getRequestType()) {
         // don't do anything if it's not the master request
         return;
     }
     if (false === strpos($event->getRequest()->getRequestUri(), 'login')) {
         if ($event->getRequest()->isXmlHttpRequest() && $event->getResponse()->getStatusCode() == "302") {
             $event->getResponse()->setStatusCode(401);
             $response = new \Symfony\Component\HttpFoundation\Response();
             $response->setStatusCode(401);
             $event->setResponse($response);
         }
     }
 }
开发者ID:hkmshb,项目名称:OpitHrm,代码行数:15,代码来源:XMLHttpSessionExpiredListener.php


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