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


PHP HttpCache::handle方法代码示例

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


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

示例1: handle

 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     if (!$request instanceof \Thelia\Core\HttpFoundation\Request) {
         $request = TheliaRequest::create($request->getUri(), $request->getMethod(), $request->getMethod() == 'GET' ? $request->query->all() : $request->request->all(), $request->cookies->all(), $request->files->all(), $request->server->all(), $request->getContent());
     }
     return parent::handle($request, $type, $catch);
 }
开发者ID:margery,项目名称:thelia,代码行数:7,代码来源:HttpCache.php

示例2: handle

 /**
  * {@inheritDoc}
  *
  * Adding the Events::PRE_HANDLE event.
  */
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     if ($this->getEventDispatcher()->hasListeners(Events::PRE_HANDLE)) {
         $event = new CacheEvent($this, $request);
         $this->getEventDispatcher()->dispatch(Events::PRE_HANDLE, $event);
         if ($event->getResponse()) {
             return $event->getResponse();
         }
     }
     return parent::handle($request, $type, $catch);
 }
开发者ID:anhpha,项目名称:reports,代码行数:16,代码来源:EventDispatchingHttpCache.php

示例3: buildAndCacheResponse

 /**
  *
  */
 protected function buildAndCacheResponse()
 {
     $controllerResolver = new ControllerResolver(array($this, 'buildResponse'));
     $kernel = new HttpKernel(new EventDispatcher(), $controllerResolver);
     if ($this->adapter->isCachingEnabled($this->request)) {
         $kernel = new HttpCache($kernel, $this->adapter->getStore($this->request), $this->adapter->getSurrogate($this->request), $this->adapter->getHttpCacheOptions($this->request));
     }
     $response = $kernel->handle($this->request);
     $this->shutDownFunctionEnabled = false;
     $response->send();
     $kernel->terminate($this->request, $response);
 }
开发者ID:mindgruve,项目名称:mg-reverse-proxy,代码行数:15,代码来源:CachedReverseProxy.php

示例4: handle

 /**
  * {@inheritdoc}
  */
 public function handle(HttpCache $cache, $uri, $alt, $ignoreErrors)
 {
     $subRequest = Request::create($uri, Request::METHOD_GET, array(), $cache->getRequest()->cookies->all(), array(), $cache->getRequest()->server->all());
     try {
         $response = $cache->handle($subRequest, HttpKernelInterface::SUB_REQUEST, true);
         if (!$response->isSuccessful()) {
             throw new \RuntimeException(sprintf('Error when rendering "%s" (Status code is %s).', $subRequest->getUri(), $response->getStatusCode()));
         }
         return $response->getContent();
     } catch (\Exception $e) {
         if ($alt) {
             return $this->handle($cache, $alt, '', $ignoreErrors);
         }
         if (!$ignoreErrors) {
             throw $e;
         }
     }
 }
开发者ID:MisatoTremor,项目名称:symfony,代码行数:21,代码来源:AbstractSurrogate.php

示例5: array

<?php

ini_set('display_errors', 1);
require_once __DIR__ . '/../vendor/autoload.php';
use Simplex;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel;
use Symfony\Component\DependencyInjection\Reference;
$request = Request::createFromGlobals();
$sc = (include __DIR__ . '/../src/container.php');
$sc->setParameter('routes', include __DIR__ . '/../src/routes.php');
$sc->register('listener.string_response', Simplex\StringResponseListener::class);
$sc->getDefinition('dispatcher')->addMethodCall('addSubscriber', array(new Reference('listener.string_response')));
$framework = $sc->get('framework');
$framework = new HttpKernel\HttpCache\HttpCache($framework, new HttpKernel\HttpCache\Store(__DIR__ . '/../cache'));
$response = $framework->handle($request);
$response->send();
开发者ID:vanekt,项目名称:framework,代码行数:17,代码来源:index.php

示例6: render_template

require_once __DIR__ . '/../vendor/autoload.php';
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing;
use Symfony\Component\HttpKernel;
use Symfony\Component\EventDispatcher\EventDispatcher;
function render_template(Request $request)
{
    extract($request->attributes->all(), EXTR_SKIP);
    ob_start();
    include sprintf(__DIR__ . '/../src/pages/%s.php', $_route);
    return new Response(ob_get_clean());
}
$request = Request::createFromGlobals();
$routes = (include __DIR__ . '/../src/app.php');
$context = new Routing\RequestContext();
$matcher = new Routing\Matcher\UrlMatcher($routes, $context);
$resolver = new HttpKernel\Controller\ControllerResolver();
$dispatcher = new EventDispatcher();
$dispatcher->addSubscriber(new Simplex\ContentLengthListener());
$dispatcher->addSubscriber(new Simplex\GoogleListener());
/*
$dispatcher = new EventDispatcher();
$dispatcher->addListener('response', array(new Simplex\ContentLengthListener(), 'onResponse'));
$dispatcher->addListener('response', array(new Simplex\GoogleListener(), 'onResponse'), -255);
*/
$framework = new Simplex\Framework($dispatcher, $matcher, $resolver);
$framework = new HttpKernel\HttpCache\HttpCache($framework, new HttpKernel\HttpCache\Store(__DIR__ . '/../cache'));
$framework->handle($request)->send();
开发者ID:Guillaume-RICHARD,项目名称:micro-framework,代码行数:29,代码来源:front.php

示例7: handle

 /**
  * Short circuit some URLs to early pass
  *
  * {@inheritdoc}
  *
  * @api
  */
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     $request->headers->set('Surrogate-Capability', 'shopware="ESI/1.0"');
     if (strpos($request->getPathInfo(), '/backend/') === 0) {
         return $this->pass($request, $catch);
     }
     if (strpos($request->getPathInfo(), '/widgets/index/refreshStatistic') === 0) {
         return $this->pass($request, $catch);
     }
     if (strpos($request->getPathInfo(), '/captcha/index/rand/') === 0) {
         return $this->pass($request, $catch);
     }
     $response = parent::handle($request, $type, $catch);
     $response->headers->remove('cache-control');
     $response->headers->addCacheControlDirective('nocache');
     return $response;
 }
开发者ID:GerDner,项目名称:luck-docker,代码行数:24,代码来源:AppCache.php

示例8: handle

 /**
  * {@inheritdoc}
  *
  * @api
  */
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     if (strpos($request->getPathInfo(), '/backend/') === 0) {
         return $this->pass($request, $catch);
     }
     return parent::handle($request, $type, $catch);
 }
开发者ID:nhp,项目名称:shopware-4,代码行数:12,代码来源:AppCache.php


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