{"action":"created","issue":{"url":"https://api.github.com/repos/thephpleague/tactician-bundle/issues/20","repository_url":"https://api.github.com/repos/thephpleague/tactician-bundle","labels_url":"https://api.github.com/repos/thephpleague/tactician-bundle/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/thephpleague/tactician-bundle/issues/20/comments","events_url":"https://api.github.com/repos/thephpleague/tactician-bundle/issues/20/events","html_url":"https://github.com/thephpleague/tactician-bundle/pull/20","id":150585994,"number":20,"title":"WIP Allow tagging handlers per bus","user":{"login":"benglass","id":1964631,"avatar_url":"https://avatars.githubusercontent.com/u/1964631?v=3","gravatar_id":"","url":"https://api.github.com/users/benglass","html_url":"https://github.com/benglass","followers_url":"https://api.github.com/users/benglass/followers","following_url":"https://api.github.com/users/benglass/following{/other_user}","gists_url":"https://api.github.com/users/benglass/gists{/gist_id}","starred_url":"https://api.github.com/users/benglass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benglass/subscriptions","organizations_url":"https://api.github.com/users/benglass/orgs","repos_url":"https://api.github.com/users/benglass/repos","events_url":"https://api.github.com/users/benglass/events{/privacy}","received_events_url":"https://api.github.com/users/benglass/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2016-04-23T19:09:14Z","updated_at":"2016-04-24T18:53:16Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/thephpleague/tactician-bundle/pulls/20","html_url":"https://github.com/thephpleague/tactician-bundle/pull/20","diff_url":"https://github.com/thephpleague/tactician-bundle/pull/20.diff","patch_url":"https://github.com/thephpleague/tactician-bundle/pull/20.patch"},"body":"Addresses #19 \r\n\r\nThere are a number of different possible ways that this feature could be implemented. Currently the bundle places all tagged handlers into a single instance of ContainerBasedHandlerLocator and relies on the user to register this handler as a middleware of their bus (or use the default tactician.middleware.command_handler service which includes it).\r\n\r\nThe approach I took was to leave that as-is for any handlers which are explicitly tagged as belonging to a specific bus. \r\n\r\nHowever if the user tags a handler for a specific bus by using the \"bus\" key in the tag definition then this code does the following:\r\n\r\n1. Do not add the handler to the default locator\r\n2. Create a new service called tactician.handler.locator.symfony.*bus_name* with only those handlers tagged explicitly for that bus\r\n\r\nThis means that if you want as soon as you tag a handler for a specific bus, that bus will now ONLY include handlers explicitly tagged for it.\r\n\r\nThis also means that the user needs to be sure they configure the bus with an instance of CommandHandlerMiddleware since they can't use the default tactician.middleware.command_handler\r\n\r\nThere are some other possible approaches improvements I thought of, I wanted to post this WIP code and get feedback before I proceed any further. Here are some other ideas\r\n\r\n1. Create a copy of the tactician.middleware.command_handler for each bus that has handlers tagged for it explicitly. This would be identical to the default command_handler but with a different locator. The user would still need to attach the right tactician.middleware.command_handler.BUS_NAME as the final middleware. \r\n2. Automatically push the command_handler onto the middleware for the bus (deviates from the way this bundle works right now where you have to include the command handler as the final middleware) \r\n3. If the user configures multiple buses we could throw an exception if they dont tag all their handler services (probably not a good idea)\r\n\r\n@rosstuck @boekkooi Let me know your thoughts, It seems like at least the first item would be necessary to make this feature easy to use (automatically create a copy of the default command_handler middleware with the custom locator if the user tags any of their handler services)"},"comment":{"url":"https://api.github.com/repos/thephpleague/tactician-bundle/issues/comments/214022552","html_url":"https://github.com/thephpleague/tactician-bundle/pull/20#issuecomment-214022552","issue_url":"https://api.github.com/repos/thephpleague/tactician-bundle/issues/20","id":214022552,"user":{"login":"benglass","id":1964631,"avatar_url":"https://avatars.githubusercontent.com/u/1964631?v=3","gravatar_id":"","url":"https://api.github.com/users/benglass","html_url":"https://github.com/benglass","followers_url":"https://api.github.com/users/benglass/followers","following_url":"https://api.github.com/users/benglass/following{/other_user}","gists_url":"https://api.github.com/users/benglass/gists{/gist_id}","starred_url":"https://api.github.com/users/benglass/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benglass/subscriptions","organizations_url":"https://api.github.com/users/benglass/orgs","repos_url":"https://api.github.com/users/benglass/repos","events_url":"https://api.github.com/users/benglass/events{/privacy}","received_events_url":"https://api.github.com/users/benglass/received_events","type":"User","site_admin":false},"created_at":"2016-04-24T18:53:15Z","updated_at":"2016-04-24T18:53:15Z","body":"@boekkooi @rosstuck I took another pass at this. We are now creating bus-specific versions of the handler locator ad command handler middleware and registering the default versions as aliases to the old service names."}}