{"action":"created","issue":{"url":"https://api.github.com/repos/symfony/symfony/issues/15321","labels_url":"https://api.github.com/repos/symfony/symfony/issues/15321/labels{/name}","comments_url":"https://api.github.com/repos/symfony/symfony/issues/15321/comments","events_url":"https://api.github.com/repos/symfony/symfony/issues/15321/events","html_url":"https://github.com/symfony/symfony/issues/15321","id":96261852,"number":15321,"title":"[Filesystem] LockHandler not injectable because of constructor argument","user":{"login":"parhamdoustdar","id":352539,"avatar_url":"https://avatars.githubusercontent.com/u/352539?v=3","gravatar_id":"","url":"https://api.github.com/users/parhamdoustdar","html_url":"https://github.com/parhamdoustdar","followers_url":"https://api.github.com/users/parhamdoustdar/followers","following_url":"https://api.github.com/users/parhamdoustdar/following{/other_user}","gists_url":"https://api.github.com/users/parhamdoustdar/gists{/gist_id}","starred_url":"https://api.github.com/users/parhamdoustdar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/parhamdoustdar/subscriptions","organizations_url":"https://api.github.com/users/parhamdoustdar/orgs","repos_url":"https://api.github.com/users/parhamdoustdar/repos","events_url":"https://api.github.com/users/parhamdoustdar/events{/privacy}","received_events_url":"https://api.github.com/users/parhamdoustdar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/symfony/symfony/labels/Filesystem","name":"Filesystem","color":"DDDDDD"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-07-21T08:46:53Z","updated_at":"2015-07-23T11:59:19Z","closed_at":null,"body":"I have a method, `run()` on a class called `CommandRunner`. `CommandRunner::run()` needs to create a lock based on an argument it receives. This makes me unable to inject the `LockHandler` class because the argument of `run()` is actually the constructor argument to `LockHandler`.\r\n\r\nIn my humble opinion, having a `LockHandlerFactory::create($filename)` will fix this. Of course, I could create this only in my own project, but I thought including this in the component would improve the testability of client code."},"comment":{"url":"https://api.github.com/repos/symfony/symfony/issues/comments/124075687","html_url":"https://github.com/symfony/symfony/issues/15321#issuecomment-124075687","issue_url":"https://api.github.com/repos/symfony/symfony/issues/15321","id":124075687,"user":{"login":"adamziel","id":205419,"avatar_url":"https://avatars.githubusercontent.com/u/205419?v=3","gravatar_id":"","url":"https://api.github.com/users/adamziel","html_url":"https://github.com/adamziel","followers_url":"https://api.github.com/users/adamziel/followers","following_url":"https://api.github.com/users/adamziel/following{/other_user}","gists_url":"https://api.github.com/users/adamziel/gists{/gist_id}","starred_url":"https://api.github.com/users/adamziel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/adamziel/subscriptions","organizations_url":"https://api.github.com/users/adamziel/orgs","repos_url":"https://api.github.com/users/adamziel/repos","events_url":"https://api.github.com/users/adamziel/events{/privacy}","received_events_url":"https://api.github.com/users/adamziel/received_events","type":"User","site_admin":false},"created_at":"2015-07-23T11:59:19Z","updated_at":"2015-07-23T11:59:19Z","body":"If I understand correctly, you need to pass an argument to the LockHandler, and the value of this argument is only available in the runtime. So, unless I am missing something important, it is not possible to define it as a service beforehand. "}}