You are here

protected function InlineFragmentRenderer::createSubRequest in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php \Symfony\Component\HttpKernel\Fragment\InlineFragmentRenderer::createSubRequest()
1 call to InlineFragmentRenderer::createSubRequest()
InlineFragmentRenderer::render in vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php
Additional available options:

File

vendor/symfony/http-kernel/Fragment/InlineFragmentRenderer.php, line 113

Class

InlineFragmentRenderer
Implements the inline rendering strategy where the Request is rendered by the current HTTP kernel.

Namespace

Symfony\Component\HttpKernel\Fragment

Code

protected function createSubRequest($uri, Request $request) {
  $cookies = $request->cookies
    ->all();
  $server = $request->server
    ->all();

  // Override the arguments to emulate a sub-request.
  // Sub-request object will point to localhost as client ip and real client ip
  // will be included into trusted header for client ip
  try {
    if ($trustedHeaderName = Request::getTrustedHeaderName(Request::HEADER_CLIENT_IP)) {
      $currentXForwardedFor = $request->headers
        ->get($trustedHeaderName, '');
      $server['HTTP_' . $trustedHeaderName] = ($currentXForwardedFor ? $currentXForwardedFor . ', ' : '') . $request
        ->getClientIp();
    }
  } catch (\InvalidArgumentException $e) {

    // Do nothing
  }
  $server['REMOTE_ADDR'] = '127.0.0.1';
  $subRequest = Request::create($uri, 'get', array(), $cookies, array(), $server);
  if ($request->headers
    ->has('Surrogate-Capability')) {
    $subRequest->headers
      ->set('Surrogate-Capability', $request->headers
      ->get('Surrogate-Capability'));
  }
  if ($session = $request
    ->getSession()) {
    $subRequest
      ->setSession($session);
  }
  return $subRequest;
}