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

8.0.x
Alex Pott 2015-07-07 14:17:12 +01:00
parent 48aa09b423
commit f3a857f133
2 changed files with 33 additions and 1 deletions

View File

@ -0,0 +1,28 @@
<?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;
}
}

View File

@ -44,7 +44,11 @@ class MonkeysInTheControlRoom implements HttpKernelInterface {
$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');