Closed mdrewek closed 3 years ago
Let me add some words on why I use bind:
rather than using Flysystem\FilesystemInterface as method type hint for DI (or aliasing the type): I use different file systems with FlySystem within one bundle. So binding these to different variable names always worked for me. I did not yet try to switch to the Mount Manager, which might be a good idea.
This seems to be an issue rather related to Symfony than to this bundle.
Does this kind of binding work for other arguments, e.g. a demo controller or the like?
Yes, I use this for different Monolog channels, for instance. So I can inject $batchLogger
which has type hint LoggerInterface
, but is then bound to batch
channel.
For Monolog, this works with all Symfony 3.4 versions. For FlySystem, it does not work for Symfony 3.4.13, but with versions before.
From your perspective, what's the recommended way to have DI inject one particular File System into a Service via autowiring?
@mdrewek
You probably need to add League\Flysystem\FilesystemInterface as an alias to League\Flysystem\Filesystem service,
something like this
services:
_defaults:
autowire: true
autoconfigure: true
oneup_flysystem.data_filesystem_filesystem:
alias: League\Flysystem\FilesystemInterface
public: true # only needed to make it accessible from service container
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I have the following setup:
With Symfony 3.4.12, it works fine. Whenever I upgrade to 3.4.13, I get the following issue;