function MonkeysInTheControlRoom::handle
Same name in other branches
- 9 core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php \Drupal\error_service_test\MonkeysInTheControlRoom::handle()
- 8.9.x core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php \Drupal\error_service_test\MonkeysInTheControlRoom::handle()
- 11.x core/modules/system/tests/modules/error_service_test/src/MonkeysInTheControlRoom.php \Drupal\error_service_test\MonkeysInTheControlRoom::handle()
File
-
core/
modules/ system/ tests/ modules/ error_service_test/ src/ MonkeysInTheControlRoom.php, line 45
Class
- MonkeysInTheControlRoom
- A http middleware designed to cause bedlam.
Namespace
Drupal\error_service_testCode
public function handle(Request $request, $type = self::MAIN_REQUEST, $catch = TRUE) : Response {
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);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.