{"action":"created","issue":{"url":"https://api.github.com/repos/PHP-DI/Silex-Bridge/issues/16","repository_url":"https://api.github.com/repos/PHP-DI/Silex-Bridge","labels_url":"https://api.github.com/repos/PHP-DI/Silex-Bridge/issues/16/labels{/name}","comments_url":"https://api.github.com/repos/PHP-DI/Silex-Bridge/issues/16/comments","events_url":"https://api.github.com/repos/PHP-DI/Silex-Bridge/issues/16/events","html_url":"https://github.com/PHP-DI/Silex-Bridge/pull/16","id":141230191,"number":16,"title":"Allow arbitrary injection into middleware and param converters","user":{"login":"felixfbecker","id":10532611,"avatar_url":"https://avatars.githubusercontent.com/u/10532611?v=3","gravatar_id":"","url":"https://api.github.com/users/felixfbecker","html_url":"https://github.com/felixfbecker","followers_url":"https://api.github.com/users/felixfbecker/followers","following_url":"https://api.github.com/users/felixfbecker/following{/other_user}","gists_url":"https://api.github.com/users/felixfbecker/gists{/gist_id}","starred_url":"https://api.github.com/users/felixfbecker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/felixfbecker/subscriptions","organizations_url":"https://api.github.com/users/felixfbecker/orgs","repos_url":"https://api.github.com/users/felixfbecker/repos","events_url":"https://api.github.com/users/felixfbecker/events{/privacy}","received_events_url":"https://api.github.com/users/felixfbecker/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/PHP-DI/Silex-Bridge/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2016-03-16T10:25:13Z","updated_at":"2016-03-20T20:22:07Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/PHP-DI/Silex-Bridge/pulls/16","html_url":"https://github.com/PHP-DI/Silex-Bridge/pull/16","diff_url":"https://github.com/PHP-DI/Silex-Bridge/pull/16.diff","patch_url":"https://github.com/PHP-DI/Silex-Bridge/pull/16.patch"},"body":"This is an implementation for #15\r\nI would love to get this merged as quickly as possible to depend on it in my projects.\r\n\r\n----------------------------------\r\n\r\n### Feature\r\nIt is now possible to inject whatever is registered in the container into route param converters and middleware via type hints. Also, as long as the arguments are type-hinted, argument position of request / response / app doesn't matter anymore. If there are no type-hints, it falls back to Silex' default argument order.\r\n\r\n### Implementation\r\nTo accomplish this, `ConverterListener` and `MiddlewareListener` are overwritten and in `Application` the default dispatcher is overwritten to use the custom classes. For application middleware, `before`/`after`/`finish` are overwritten aswell.\r\n\r\nFor DRY reasons the injection logic is done in separate classes (`BeforeMiddlewareCaller`, `AfterMiddlewareCaller`, `ConverterCaller`). This allows the application middleware and route middleware to share the same logic and also for all event listeners to share the same instance of the caller and `ParameterResolver` objects.\r\n\r\n### Tests\r\n`ConverterTest` and `MiddlewareTest` test that both arbitrary injection is possible and the old behaviour still works.\r\n\r\n### Docs\r\nI altered the README to highlight that injection works not only for controllers but also for converters and middleware and added two examples.\r\n\r\n### BC Breaks\r\nNone\r\n\r\n----------------------------\r\n\r\nAny thoughts / objections?\r\n"},"comment":{"url":"https://api.github.com/repos/PHP-DI/Silex-Bridge/issues/comments/199010748","html_url":"https://github.com/PHP-DI/Silex-Bridge/pull/16#issuecomment-199010748","issue_url":"https://api.github.com/repos/PHP-DI/Silex-Bridge/issues/16","id":199010748,"user":{"login":"mnapoli","id":720328,"avatar_url":"https://avatars.githubusercontent.com/u/720328?v=3","gravatar_id":"","url":"https://api.github.com/users/mnapoli","html_url":"https://github.com/mnapoli","followers_url":"https://api.github.com/users/mnapoli/followers","following_url":"https://api.github.com/users/mnapoli/following{/other_user}","gists_url":"https://api.github.com/users/mnapoli/gists{/gist_id}","starred_url":"https://api.github.com/users/mnapoli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mnapoli/subscriptions","organizations_url":"https://api.github.com/users/mnapoli/orgs","repos_url":"https://api.github.com/users/mnapoli/repos","events_url":"https://api.github.com/users/mnapoli/events{/privacy}","received_events_url":"https://api.github.com/users/mnapoli/received_events","type":"User","site_admin":false},"created_at":"2016-03-20T20:22:07Z","updated_at":"2016-03-20T20:22:07Z","body":"Thanks for your answers. I'm good for merging, :+1: for squashing"}}