thephpleague / tactician-bundle

Bundle to integrate Tactician with Symfony projects
MIT License
245 stars 43 forks source link

Handlers are not picked up by Tactician #114

Closed sarjon closed 5 years ago

sarjon commented 5 years ago

Hey guys,

so I've faced weird problem. When I define handlers in config/services.yaml it all works well, but once I move my handlers into separate file, lets say config/services/command_handlers.yaml and import that file into config/service.yaml, those handlers defined in separate file are not picked up by Tactician. :confused:

Any ideas of what I'm missing? Thanks in advance! :slightly_smiling_face:

Btw, I'm on Symfony 4.3 and PHP 7.3.

sarjon commented 5 years ago

Haha, seems I've figured it out. The problem was with how services get loaded into container. This is simplified version of how my services.yaml looks like:

imports:
  #  This will import tagged command handlers from external file
  - { resource: services/command_handlers.yaml } 

services:
 # This will override previously imported command handlers thus removing tags
  App\:
    resource: '../src/*'

So what I did is excluded my command handlers directory from being loaded again:

imports:
  - { resource: services/command_handlers.yaml } 

services:
  App\:
    resource: '../src/*'
    exclude:
        - './src/CommandHandler/*' # Exclude loading command handlers once again

Hopefully this could help others with the same issue. :stuck_out_tongue:

temple commented 4 years ago

This issue has not been resolved. The problem stills appearing making impossible to define handlers separately. Definitely, the previous answer is not an issue fix.

rosstuck commented 4 years ago

Hi, do you think you can create a reproducible test case for this? :)

On Thu, Jul 9, 2020, 4:31 PM Xavi Subirà notifications@github.com wrote:

This issue has not been resolved. The problem stills appearing making impossible to define handlers separately. Definitely, the previous answer is not an issue fix.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/thephpleague/tactician-bundle/issues/114#issuecomment-656162796, or unsubscribe https://github.com/notifications/unsubscribe-auth/AABD2TXNAVO37HTBQ3WFPOLR2XIDBANCNFSM4INEF6EA .