Issue #2852515 by dawehner, timmillwood: $interface is still set from the previous loop in tagged services compilation

8.4.x
xjm 2017-02-21 09:37:03 +00:00
parent f57baee520
commit bbd96cc9a0
2 changed files with 6 additions and 2 deletions

View File

@ -77,6 +77,7 @@ class TaggedHandlersPass implements CompilerPassInterface {
public function process(ContainerBuilder $container) {
foreach ($container->findTaggedServiceIds('service_collector') as $consumer_id => $passes) {
foreach ($passes as $pass) {
$interface = NULL;
$tag = isset($pass['tag']) ? $pass['tag'] : $consumer_id;
$method_name = isset($pass['call']) ? $pass['call'] : 'addHandler';
$required = isset($pass['required']) ? $pass['required'] : FALSE;

View File

@ -64,13 +64,16 @@ class TaggedHandlersPassTest extends UnitTestCase {
* Tests consumer with missing interface in non-production environment.
*
* @expectedException \Symfony\Component\DependencyInjection\Exception\LogicException
* @expectedExceptionMessage Service consumer 'consumer_id' class method Drupal\Tests\Core\DependencyInjection\Compiler\InvalidConsumer::addHandler() has to type-hint an interface.
* @expectedExceptionMessage Service consumer 'consumer_id1' class method Drupal\Tests\Core\DependencyInjection\Compiler\InvalidConsumer::addHandler() has to type-hint an interface.
* @covers ::process
*/
public function testProcessMissingInterface() {
$container = $this->buildContainer();
$container
->register('consumer_id', __NAMESPACE__ . '\InvalidConsumer')
->register('consumer_id0', __NAMESPACE__ . '\ValidConsumer')
->addTag('service_collector');
$container
->register('consumer_id1', __NAMESPACE__ . '\InvalidConsumer')
->addTag('service_collector');
$handler_pass = new TaggedHandlersPass();