Skip to content
Snippets Groups Projects
Commit a10d5be2 authored by catch's avatar catch
Browse files

Issue #2259337 by sun, chx: Do not hide the error messages in TaggedHandlersPass.

parent 68d6316b
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
...@@ -89,9 +89,6 @@ public function process(ContainerBuilder $container) { ...@@ -89,9 +89,6 @@ public function process(ContainerBuilder $container) {
$accepts_priority = isset($params[1]) && $params[1]->getName() === 'priority'; $accepts_priority = isset($params[1]) && $params[1]->getName() === 'priority';
if (!isset($interface)) { if (!isset($interface)) {
if ($container->getParameter('kernel.environment') === 'prod') {
continue;
}
throw new LogicException(vsprintf("Service consumer '%s' class method %s::%s() has to type-hint an interface.", array( throw new LogicException(vsprintf("Service consumer '%s' class method %s::%s() has to type-hint an interface.", array(
$consumer_id, $consumer_id,
$consumer->getClass(), $consumer->getClass(),
...@@ -106,9 +103,6 @@ public function process(ContainerBuilder $container) { ...@@ -106,9 +103,6 @@ public function process(ContainerBuilder $container) {
// Validate the interface. // Validate the interface.
$handler = $container->getDefinition($id); $handler = $container->getDefinition($id);
if (!is_subclass_of($handler->getClass(), $interface)) { if (!is_subclass_of($handler->getClass(), $interface)) {
if ($container->getParameter('kernel.environment') === 'prod') {
continue;
}
throw new LogicException("Service '$id' for consumer '$consumer_id' does not implement $interface."); throw new LogicException("Service '$id' for consumer '$consumer_id' does not implement $interface.");
} }
$handlers[$id] = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0; $handlers[$id] = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
......
...@@ -73,24 +73,6 @@ public function testProcessMissingInterface() { ...@@ -73,24 +73,6 @@ public function testProcessMissingInterface() {
$handler_pass->process($container); $handler_pass->process($container);
} }
/**
* Tests consumer with missing interface in production environment.
*
* @covers ::process
*/
public function testProcessMissingInterfaceProd() {
$container = $this->buildContainer('prod');
$container
->register('consumer_id', __NAMESPACE__ . '\InvalidConsumer')
->addTag('service_collector');
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
$this->assertCount(1, $container->getDefinitions());
$this->assertFalse($container->getDefinition('consumer_id')->hasMethodCall('addHandler'));
}
/** /**
* Tests one consumer and two handlers. * Tests one consumer and two handlers.
* *
...@@ -205,35 +187,6 @@ public function testProcessInterfaceMismatch() { ...@@ -205,35 +187,6 @@ public function testProcessInterfaceMismatch() {
$handler_pass->process($container); $handler_pass->process($container);
} }
/**
* Tests interface validation in production environment.
*
* @covers ::process
*/
public function testProcessInterfaceMismatchProd() {
$container = $this->buildContainer('prod');
$container
->register('consumer_id', __NAMESPACE__ . '\ValidConsumer')
->addTag('service_collector');
$container
->register('handler1', __NAMESPACE__ . '\InvalidHandler')
->addTag('consumer_id');
$container
->register('handler2', __NAMESPACE__ . '\ValidHandler')
->addTag('consumer_id', array(
'priority' => 10,
));
$handler_pass = new TaggedHandlersPass();
$handler_pass->process($container);
$method_calls = $container->getDefinition('consumer_id')->getMethodCalls();
$this->assertCount(1, $method_calls);
$this->assertEquals(new Reference('handler2'), $method_calls[0][1][0]);
$this->assertEquals(10, $method_calls[0][1][1]);
}
} }
interface HandlerInterface { interface HandlerInterface {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment