function SystemTestController::shutdownFunctions

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php \Drupal\system_test\Controller\SystemTestController::shutdownFunctions()
  2. 10 core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php \Drupal\system_test\Controller\SystemTestController::shutdownFunctions()
  3. 9 core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php \Drupal\system_test\Controller\SystemTestController::shutdownFunctions()
  4. 8.9.x core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php \Drupal\system_test\Controller\SystemTestController::shutdownFunctions()

A simple page callback which adds a register shutdown function.

Attributes

#[Route(path: '/system-test/shutdown-functions/{arg1}/{arg2}', name: 'system_test.shutdown_functions', requirements: [ '_access' => 'TRUE', ])]

File

core/modules/system/tests/modules/system_test/src/Controller/SystemTestController.php, line 443

Class

SystemTestController
Controller routines for system_test routes.

Namespace

Drupal\system_test\Controller

Code

public function shutdownFunctions($arg1, $arg2) {
  drupal_register_shutdown_function('_system_test_first_shutdown_function', $arg1, $arg2);
  // If using PHP-FPM then fastcgi_finish_request() will have been fired
  // preventing further output to the browser which means that the escaping of
  // the exception message can not be tested.
  // @see _drupal_shutdown_function()
  // @see \Drupal\system\Tests\System\ShutdownFunctionsTest
  if (function_exists('fastcgi_finish_request') || ob_get_status()) {
    return [
      '#markup' => 'The response will flush before shutdown functions are called.',
    ];
  }
  return [];
}

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