diff --git a/src/DI/Extensions/DecoratorExtension.php b/src/DI/Extensions/DecoratorExtension.php index 2de747c04..35ad35ff1 100644 --- a/src/DI/Extensions/DecoratorExtension.php +++ b/src/DI/Extensions/DecoratorExtension.php @@ -61,7 +61,8 @@ public function addTags($type, array $tags) private function findByType($type) { return array_filter($this->getContainerBuilder()->getDefinitions(), function ($def) use ($type) { - return is_a($def->getType(), $type, true) || is_a($def->getImplement(), $type, true); + return is_a($def->getImplement(), $type, true) + || ($def->getImplementMode() !== $def::IMPLEMENT_MODE_GET && is_a($def->getType(), $type, true)); }); } } diff --git a/tests/DI/DecoratorExtension.factories.accessor.phpt b/tests/DI/DecoratorExtension.factories.accessor.phpt new file mode 100644 index 000000000..622f6e3bb --- /dev/null +++ b/tests/DI/DecoratorExtension.factories.accessor.phpt @@ -0,0 +1,47 @@ +addExtension('decorator', new Nette\DI\Extensions\DecoratorExtension); +$container = createContainer($compiler, ' +decorator: + Foo: + inject: yes + FooAccessor: + tags: [a] +services: + foo: Foo + acc: {implement: FooAccessor} +'); + + +$builder = $compiler->getContainerBuilder(); + +Assert::true($builder->getDefinition('foo')->getTag('inject')); +Assert::null($builder->getDefinition('foo')->getTag('a')); + +Assert::null($builder->getDefinition('acc')->getTag('inject')); +Assert::true($builder->getDefinition('acc')->getTag('a'));