function LanguageTestController::testSubRequest

Same name in other branches
  1. 9 core/modules/language/tests/language_test/src/Controller/LanguageTestController.php \Drupal\language_test\Controller\LanguageTestController::testSubRequest()
  2. 10 core/modules/language/tests/language_test/src/Controller/LanguageTestController.php \Drupal\language_test\Controller\LanguageTestController::testSubRequest()
  3. 11.x core/modules/language/tests/language_test/src/Controller/LanguageTestController.php \Drupal\language_test\Controller\LanguageTestController::testSubRequest()

Uses a sub request to retrieve the 'user' page.

Return value

\Symfony\Component\HttpFoundation\Response The kernels response to the sub request.

1 string reference to 'LanguageTestController::testSubRequest'
language_test.routing.yml in core/modules/language/tests/language_test/language_test.routing.yml
core/modules/language/tests/language_test/language_test.routing.yml

File

core/modules/language/tests/language_test/src/Controller/LanguageTestController.php, line 120

Class

LanguageTestController
Controller routines for language_test routes.

Namespace

Drupal\language_test\Controller

Code

public function testSubRequest() {
    $request = Request::createFromGlobals();
    $server = $request->server
        ->all();
    if (basename($server['SCRIPT_FILENAME']) != basename($server['SCRIPT_NAME'])) {
        // We need this for when the test is executed by run-tests.sh.
        // @todo Remove this once run-tests.sh has been converted to use a Request
        //   object.
        $server['SCRIPT_FILENAME'] = $server['SCRIPT_NAME'];
        $base_path = ltrim($server['REQUEST_URI'], '/');
    }
    else {
        $base_path = $request->getBasePath();
    }
    $sub_request = Request::create($base_path . '/user', 'GET', $request->query
        ->all(), $request->cookies
        ->all(), [], $server);
    return $this->httpKernel
        ->handle($sub_request, HttpKernelInterface::SUB_REQUEST);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.