File tree Expand file tree Collapse file tree 2 files changed +12
-5
lines changed
src/DependencyInjection/Compiler
tests/Functional/SmokeTest Expand file tree Collapse file tree 2 files changed +12
-5
lines changed Original file line number Diff line number Diff line change @@ -23,12 +23,16 @@ public function process(ContainerBuilder $container)
2323 {
2424 foreach ($ container ->findTaggedServiceIds ($ this ->tagName ) as $ serviceId => $ tags ) {
2525 foreach ($ tags as $ tagAttributes ) {
26-
27- // if tag attributes are set, skip
26+ // if tag attribute is set, skip
2827 if (isset ($ tagAttributes [$ this ->tagAttribute ])) {
2928 continue ;
3029 }
3130
31+ $ registerPublicMethods = false ;
32+ if (isset ($ tagAttributes ['register_public_methods ' ]) && true === $ tagAttributes ['register_public_methods ' ]) {
33+ $ registerPublicMethods = true ;
34+ }
35+
3236 $ definition = $ container ->getDefinition ($ serviceId );
3337
3438 // check if service id is class name
@@ -37,7 +41,6 @@ public function process(ContainerBuilder $container)
3741 $ methods = $ reflectionClass ->getMethods (\ReflectionMethod::IS_PUBLIC );
3842
3943 $ tagAttributes = [];
40-
4144 foreach ($ methods as $ method ) {
4245 if (true === $ method ->isConstructor ()) {
4346 continue ;
@@ -47,6 +50,10 @@ public function process(ContainerBuilder $container)
4750 continue ;
4851 }
4952
53+ if (false === $ registerPublicMethods && '__invoke ' !== $ method ->getName ()) {
54+ continue ;
55+ }
56+
5057 $ parameters = $ method ->getParameters ();
5158
5259 // if no param or optional param, skip
Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ services:
1010 auto_command_handler_using_public_method :
1111 class : SimpleBus\SymfonyBridge\Tests\Functional\SmokeTest\Auto\AutoCommandHandlerUsingPublicMethod
1212 tags :
13- - { name: command_handler }
13+ - { name: command_handler, register_public_methods: true }
1414
1515 auto_event_subscriber_using_invoke :
1616 class : SimpleBus\SymfonyBridge\Tests\Functional\SmokeTest\Auto\AutoEventSubscriberUsingInvoke
@@ -20,4 +20,4 @@ services:
2020 auto_event_subscriber_using_public_method :
2121 class : SimpleBus\SymfonyBridge\Tests\Functional\SmokeTest\Auto\AutoEventSubscriberUsingPublicMethod
2222 tags :
23- - { name: event_subscriber }
23+ - { name: event_subscriber, register_public_methods: true }
You can’t perform that action at this time.
0 commit comments