1up-lab / OneupFlysystemBundle

A Flysystem integration for your Symfony projects.
MIT License
630 stars 118 forks source link

[Question] dynamically change/inject filesystems #206

Closed pinksnotdead closed 4 years ago

pinksnotdead commented 4 years ago

Could someone help me with my problem?

https://stackoverflow.com/questions/60019528/oneupflysystembundle-dynamically-change-inject-filesystems-in-symfony

bytehead commented 4 years ago

I think I don't understand your requirements. What are you trying to achieve?

pinksnotdead commented 4 years ago

I need a service connecting to filesystem, but it have to be more dynamic. StorageConnector must be as service, because i will use this in few places and thats why it need to have ability to dynamically inject custom filesystem

pinksnotdead commented 4 years ago

UPDATE it would be simplified to not use Depency Injection in my service: public function __construct(FilesystemInterface $firstFilesystem)

but use inside a method for example: $storage = new Filesystem('storageName') but i dont know which class to use

bytehead commented 4 years ago

I still don't get it. You can't dynamically change the services you inject by dependency injection. DI configuration will be precompiled and stored in cache. Here is a list of all types of injection in the service container: https://symfony.com/doc/current/service_container/injection_types.html

I'm closing this, as it is not a problem of this bundle.