-
Notifications
You must be signed in to change notification settings - Fork 72
feat: Allow custom adapter registration #182
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 3.x
Are you sure you want to change the base?
Conversation
This PR implements a solution to the issue discussed in thephpleague#181, enabling external bundles to register their custom storage adapters with Flysystem Bundle without requiring them to be directly added to the main bundle's codebase. I had to remove the `@internal` annotation from `AdapterDefinitionBuilderInterface` and `AbstractAdapterDefinitionBuilder` to allow them to be referenced by other bundles. ## Usage Example External bundles can now register their adapters as follows: ``` php class AzureBlobStorageAdapterBundle extends Bundle { /** * {@inheritdoc} */ public function build(ContainerBuilder $container): void { parent::build($container); /** @var FlysystemExtension $extension */ $extension = $container->getExtension('flysystem'); $extension->addAdapterDefinitionBuilder(new AzureOssAdapterDefinitionBuilder()); } } ```
Yes, that’s one way to do it. You’d also need to ensure the adapter name doesn’t conflict with another, or have a clear strategy for handling duplicates. Personally, I’d lean toward simply disallowing duplicate names. |
I tried to look for examples of how this situation was handled in other Symfony components. For the examples I found (Messenger, Mailer), they chose the "first one wins" approach. Given this, do you still think it's necessary to check for potential duplicates? If so, I can take care of it and then add tests if the rest of the modifications seem correct to you. |
So for now, it's fine if the first one wins -- we'll see based on the use case. |
I've been thinking more broadly about how we can open up the FlysystemBundle to third-party adapter builders in a clean and sustainable way. Before considering the removal of the current Proposed changes
Let me know what you think of this direction – happy to break it into smaller PRs if needed! poke @tgalopin I'll start some parts soon, these just up in my todolist. |
This PR implements a solution to the issue discussed in #181, enabling external bundles to register their custom storage adapters with Flysystem Bundle without requiring them to be directly added to the main bundle's codebase.
I had to remove the
@internal
annotation fromAdapterDefinitionBuilderInterface
andAbstractAdapterDefinitionBuilder
to allow them to be referenced by other bundles.Usage Example
External bundles can now register their adapters as follows:
If you think this is the right approach I can add a test to my PR.