當前位置: 首頁>>代碼示例>>PHP>>正文


PHP HttpKernel\HttpKernelInterface類代碼示例

本文整理匯總了PHP中Symfony\Component\HttpKernel\HttpKernelInterface的典型用法代碼示例。如果您正苦於以下問題:PHP HttpKernelInterface類的具體用法?PHP HttpKernelInterface怎麽用?PHP HttpKernelInterface使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了HttpKernelInterface類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: previewContentAction

 /**
  * @throws NotImplementedException If Content is missing location as this is not supported in current version
  */
 public function previewContentAction(Request $request, $contentId, $versionNo, $language, $siteAccessName = null)
 {
     $this->previewHelper->setPreviewActive(true);
     try {
         $content = $this->contentService->loadContent($contentId, array($language), $versionNo);
         $location = $this->locationProvider->loadMainLocation($contentId);
         if (!$location instanceof Location) {
             throw new NotImplementedException("Preview for content without locations");
         }
         $this->previewHelper->setPreviewedContent($content);
         $this->previewHelper->setPreviewedLocation($location);
     } catch (UnauthorizedException $e) {
         throw new AccessDeniedException();
     }
     if (!$this->authorizationChecker->isGranted(new AuthorizationAttribute('content', 'versionread', array('valueObject' => $content)))) {
         throw new AccessDeniedException();
     }
     $siteAccess = $this->previewHelper->getOriginalSiteAccess();
     // Only switch if $siteAccessName is set and different from original
     if ($siteAccessName !== null && $siteAccessName !== $siteAccess->name) {
         $siteAccess = $this->previewHelper->changeConfigScope($siteAccessName);
     }
     $response = $this->kernel->handle($this->getForwardRequest($location, $content, $siteAccess, $request), HttpKernelInterface::SUB_REQUEST);
     $response->headers->remove('cache-control');
     $response->headers->remove('expires');
     $this->previewHelper->restoreConfigScope();
     $this->previewHelper->setPreviewActive(false);
     return $response;
 }
開發者ID:nlescure,項目名稱:ezpublish-kernel,代碼行數:32,代碼來源:PreviewController.php

示例2: redirect

 protected function redirect($params, $event)
 {
     $subRequest = $this->request->duplicate(array(), null, $params);
     $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::SUB_REQUEST);
     $event->setResponse($response);
     $event->stopPropagation();
 }
開發者ID:ngodfraind,項目名稱:SocialmediaBundle,代碼行數:7,代碼來源:ResourceActionsListener.php

示例3: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     // always set the session onto the request object.
     $request->setSession($this->session);
     // we only need to manage the session for the master request.
     // subrequests will have the session available anyways, but we will
     // be closing and setting the cookie for the master request only.
     if ($type !== HttpKernelInterface::MASTER_REQUEST) {
         return $this->kernel->handle($request, $type, $catch);
     }
     // the session may have been manually started before the middleware is
     // invoked - in this case, we cross our fingers and hope the session has
     // properly initialised itself
     if (!$this->session->isStarted()) {
         $this->initSession($request);
     }
     $response = $this->kernel->handle($request, $type, $catch);
     // if the session has started, save it and attach the session cookie. if
     // the session has not started, there is nothing to save and there is no
     // point in attaching a cookie to persist it.
     if ($this->session->isStarted()) {
         $this->closeSession($request, $response);
     }
     return $response;
 }
開發者ID:autarky,項目名稱:framework,代碼行數:28,代碼來源:SessionMiddleware.php

示例4: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     $route = $request->getPathInfo();
     // We have an active login
     if ($this->sessionAuth->check()) {
         switch ($route) {
             case '/login':
                 $returnUri = $request->query->get('uri', $request->attributes->get('stack.url_map.prefix', '/'));
                 return new RedirectResponse($returnUri);
                 break;
             case '/logout':
                 $this->sessionAuth->logout();
                 return new RedirectResponse($request->attributes->get('stack.url_map.prefix', '/'));
                 break;
             default:
                 $caller = $this->sessionAuth->getCurrentCaller();
                 $request->attributes->set('stack.authn.token', $caller->getLoginToken());
                 if ($this->options['delegateCaller']) {
                     $request->attributes->set('stack.authn.caller', $caller);
                 }
                 break;
         }
     } elseif ($route !== '/login') {
         $routePrefix = $request->attributes->get('stack.url_map.prefix', '');
         $fullRoute = $request->server->get('PATH_INFO', '/');
         return new RedirectResponse(sprintf('%s/%s?uri=%s', $routePrefix, $this->options['loginUri'], $fullRoute));
     }
     return $this->app->handle($request, $type, $catch);
 }
開發者ID:guardianphp,項目名稱:stack-integration,代碼行數:32,代碼來源:Authentication.php

示例5: getAuditFields

 /**
  * @return string Json encoded
  */
 protected function getAuditFields()
 {
     $path = ['_controller' => 'OroDataAuditBundle:Api/Rest/Audit:getFields'];
     $subRequest = $this->request->duplicate(['_format' => 'json'], null, $path);
     $response = $this->httpKernel->handle($subRequest, HttpKernelInterface::MASTER_REQUEST);
     return $response->getContent();
 }
開發者ID:Maksold,項目名稱:platform,代碼行數:10,代碼來源:SegmentWidgetOptionsListener.php

示例6: onKernelRequest

 /**
  * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event
  */
 public function onKernelRequest(GetResponseEvent $event)
 {
     if ($event->getRequestType() != HttpKernelInterface::MASTER_REQUEST) {
         return;
     }
     // @todo make endpoint(s) customizable
     if ($event->getRequest()->getMethod() !== 'POST') {
         return;
     }
     if ($event->getRequest()->getPathInfo() != '/xmlrpc' && $event->getRequest()->getPathInfo() != '/xmlrpc.php') {
         return;
     }
     try {
         $request = $this->requestGenerator->generateFromRequest($event->getRequest());
         if (isset($this->logger)) {
             $this->logger->debug((string) $request);
         }
     } catch (UnexpectedValueException $e) {
         $event->setResponse(new Response("Invalid request XML\n" . $e->getMessage(), 400));
         return;
     }
     // @todo refactor to dynamically set follow-up events instead of testing (cors bundle like)
     $request->attributes->set('IsXmlRpcRequest', true);
     $requestContext = new RequestContext();
     $requestContext->fromRequest($request);
     $originalContext = $this->router->getContext();
     $this->router->setContext($requestContext);
     $response = $this->httpKernel->handle($request);
     $event->setResponse($response);
     $this->router->setContext($originalContext);
     if ($response instanceof Response) {
         $event->setResponse($response);
     }
 }
開發者ID:bdunogier,項目名稱:xmlrpcbundle,代碼行數:37,代碼來源:RequestEventListener.php

示例7: onRequest

 /**
  * Handle a request using a HttpKernelInterface implementing application.
  *
  * @param \React\Http\Request $request
  * @param \React\Http\Response $response
  */
 public function onRequest(ReactRequest $request, ReactResponse $response)
 {
     if (null === $this->application) {
         return;
     }
     $content = '';
     $headers = $request->getHeaders();
     $contentLength = isset($headers['Content-Length']) ? (int) $headers['Content-Length'] : 0;
     $request->on('data', function ($data) use($request, $response, &$content, $contentLength) {
         // read data (may be empty for GET request)
         $content .= $data;
         // handle request after receive
         if (strlen($content) >= $contentLength) {
             $syRequest = self::mapRequest($request, $content);
             try {
                 $syResponse = $this->application->handle($syRequest);
             } catch (\Exception $exception) {
                 $response->writeHead(500);
                 // internal server error
                 $response->end();
                 return;
             }
             self::mapResponse($response, $syResponse);
             if ($this->application instanceof TerminableInterface) {
                 $this->application->terminate($syRequest, $syResponse);
             }
         }
     });
 }
開發者ID:nghenglim,項目名稱:php-pm-httpkernel,代碼行數:35,代碼來源:HttpKernel.php

示例8: handle

 /**
  * {@inheritDoc}
  */
 public function handle(Request $request, $type = HttpKernelInterface::MASTER_REQUEST, $catch = true)
 {
     if (HttpKernelInterface::MASTER_REQUEST !== $type) {
         return $this->app->handle($request, $type, $catch);
     }
     $session = new SymfonySession();
     $request->setSession($session);
     if ($this->start) {
         $cookies = $request->cookies;
         if ($cookies->has($session->getName())) {
             $session->setId($cookies->get($session->getName()));
         } else {
             //starts the session if no session exists
             $session->start();
             $session->migrate(false);
         }
         $session->start();
     }
     $response = $this->app->handle($request, $type, $catch);
     if ($session && $session->isStarted()) {
         $session->save();
         $params = array_merge(session_get_cookie_params(), $this->cookieParams);
         if (array_key_exists('domain', $this->cookieParams)) {
             $response->headers->clearCookie($session->getName());
         }
         $cookie = new Cookie($session->getName(), $session->getId(), 0 === $params['lifetime'] ? 0 : $request->server->get('REQUEST_TIME') + $params['lifetime'], $params['path'], $params['domain'], $params['secure'], $params['httponly']);
         $response->headers->setCookie($cookie);
     }
     return $response;
 }
開發者ID:evaneos,項目名稱:pyrite,代碼行數:33,代碼來源:Session.php

示例9: __construct

    /**
     * Constructor.
     *
     * @param HttpKernelInterface $kernel An HttpKernelInterface instance
     */
    public function __construct(HttpKernelInterface $kernel)
    {
        $store = new Store($kernel->getCacheDir().'/http_cache');
        $esi = new Esi();

        parent::__construct($kernel, $store, $esi, array_merge(array('debug' => $kernel->isDebug()), $this->getOptions()));
    }
開發者ID:ruudk,項目名稱:symfony,代碼行數:12,代碼來源:HttpCache.php

示例10: onRequest

 /**
  * Handle a request
  *
  * @param ReactRequest  $request
  * @param ReactResponse $response
  */
 public function onRequest(ReactRequest $request, ReactResponse $response)
 {
     $content = '';
     $headers = $request->getHeaders();
     $contentLength = isset($headers['Content-Length']) ? (int) $headers['Content-Length'] : 0;
     $request->on('data', function ($data) use($request, $response, &$content, $contentLength) {
         // Read data (may be empty for GET request)
         $content .= $data;
         // Handle request after receive
         if (strlen($content) >= $contentLength) {
             $symfonyRequest = static::mapRequest($request, $content);
             try {
                 // Execute
                 $symfonyResponse = $this->application->handle($symfonyRequest);
             } catch (\Throwable $t) {
                 // Executed only in PHP 7, will not match in PHP 5.x
                 $this->fatalError($response, $t);
                 return;
             } catch (\Exception $e) {
                 // Executed only in PHP 5.x, will not be reached in PHP 7
                 $this->fatalError($response, $e);
                 return;
             }
             static::mapResponse($response, $symfonyResponse);
             if ($this->application instanceof SymfonyHttpKernel\TerminableInterface) {
                 $this->application->terminate($symfonyRequest, $symfonyResponse);
             }
         }
     });
 }
開發者ID:M6Web,項目名稱:PhpProcessManagerBundle,代碼行數:36,代碼來源:HttpKernel.php

示例11: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE)
 {
     // TODO Probably we can move here the database log start and the initial
     //   read of memory usage.
     Timer::start('devel_page');
     return $this->httpKernel->handle($request, $type, $catch);
 }
開發者ID:KenG01,項目名稱:Achieve-D8,代碼行數:10,代碼來源:DevelMiddleware.php

示例12: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE)
 {
     if (\Drupal::state()->get('error_service_test.break_bare_html_renderer')) {
         // Let the bedlam begin.
         // 1) Force a container rebuild.
         /** @var \Drupal\Core\DrupalKernelInterface $kernel */
         $kernel = \Drupal::service('kernel');
         $kernel->rebuildContainer();
         // 2) Fetch the in-situ container builder.
         $container = ErrorServiceTestServiceProvider::$containerBuilder;
         // Ensure the compiler pass worked.
         if (!$container) {
             throw new \Exception('Oh oh, monkeys stole the ServiceProvider.');
         }
         // Stop the theme manager from being found - and triggering error
         // maintenance mode.
         $container->removeDefinition('theme.manager');
         // Mash. Mash. Mash.
         \Drupal::setContainer($container);
         throw new \Exception('Oh oh, bananas in the instruments.');
     }
     if (\Drupal::state()->get('error_service_test.break_logger')) {
         throw new \Exception('Deforestation');
     }
     return $this->app->handle($request, $type, $catch);
 }
開發者ID:HakS,項目名稱:drupal8_training,代碼行數:29,代碼來源:MonkeysInTheControlRoom.php

示例13: rebootKernel

 /**
  * After each scenario, reboot the kernel.
  */
 public function rebootKernel()
 {
     $this->kernel->flush();
     $laravel = new LaravelBooter($this->kernel->basePath(), $this->kernel->environmentFile());
     $this->context->getSession('laravel')->getDriver()->reboot($this->kernel = $laravel->boot());
     $this->setAppOnContext();
 }
開發者ID:john-main-croud,項目名稱:Behat-Laravel-Extension,代碼行數:10,代碼來源:KernelAwareInitializer.php

示例14: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = TRUE)
 {
     if ($request->headers->has('Accept')) {
         $request->setRequestFormat($request->getFormat($request->headers->get('Accept')));
     }
     return $this->httpKernel->handle($request, $type, $catch);
 }
開發者ID:Jbartsch,項目名稱:travelbruh-api,代碼行數:10,代碼來源:FormatSetter.php

示例15: handle

 /**
  * {@inheritdoc}
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     /** @var LaravelDebugbar $debugbar */
     $debugbar = $this->app['debugbar'];
     $response = $this->kernel->handle($request, $type, $catch);
     return $debugbar->modifyResponse($request, $response);
 }
開發者ID:ningcaichen,項目名稱:laravel-4.1-quick-start-cn,代碼行數:10,代碼來源:Middleware.php


注:本文中的Symfony\Component\HttpKernel\HttpKernelInterface類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。