Commit f3a857f1 authored by alexpott's avatar alexpott
Browse files

Issue #2527710 by Fabianx: Decouple Error testing from running with container builder

parent 48aa09b4
<?php
/**
* @file
* Contains \Drupal\error_service_test\ErrorServiceTestServiceProvider.
*/
namespace Drupal\error_service_test;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\DependencyInjection\ServiceModifierInterface;
class ErrorServiceTestServiceProvider implements ServiceModifierInterface {
/**
* The in-situ container builder.
*
* @var \Drupal\Core\DependencyInjection\ContainerBuilder
*/
public static $containerBuilder;
/**
* {@inheritdoc}
*/
public function alter(ContainerBuilder $container) {
static::$containerBuilder = $container;
}
}
......@@ -44,7 +44,11 @@ public function handle(Request $request, $type = self::MASTER_REQUEST, $catch =
$kernel = \Drupal::service('kernel');
$kernel->rebuildContainer();
// 2) Fetch the in-situ container builder.
$container = $kernel->getContainer();
$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');
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment