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
Feature/prepend configs #8
Conversation
I'm totally convinced of the need for the As a note to myself, this would require a new major release, since changes are BC-breaks (when upgrading, people will have to implement the |
This is not necessary for //src/ExtensionWithPlugins.php
public function prepend(ContainerBuilder $container)
{
foreach ($this->registeredPlugins as $plugin) {
if ($plugin instanceof PrependExtensionInterface) {
$plugin->prepend($container);
}
}
} With this way, only one file is modified and plugins do not need to have a void |
@Spomky you're right, but boot() or build() aren't needed too, and there are in the BundlePlugin interface, so I added prepend() method in the same way: added to the interface and implemented (void) in SimpleBundlePlugin |
Yes in some cases these methods aren't needed but executed. Off topic: What is the best way (performance, DX)?
With solution 1., the @matthiasnoback what do you think if new interfaces are created to avoid empty methods? ...
interface Loadable
{
public function load(array $pluginConfiguration, ContainerBuilder $container);
} ...
interface Configurable
{
public function addConfiguration(ArrayNodeDefinition $pluginNode);
} ...
interface Buildable
{
public function build(ContainerBuilder $container);
} ...
interface Bootable
{
public function boot(ContainerInterface $container);
} |
Thanks for brining this up. |
I would not care too much about performance here as this code path is only executed when/before the container is compiled and from the developer's point of view I'd say it's easier to implement an extra interface when you need that functionality than to let every plugin developer bother with another method they don't really need. |
Agreed, however: having all these interfaces is not necessarily a good thing. I don't like all the |
Should be closed as already implemented by #12 |
Okay, I had forgotten about this entirely. I'll trust you on your word @Spomky :) |
Added prepend methods to BundlePlugin interface and ExtensionWithPlugins (having this class implement PrependExtensionInterface), so plugins have an opportunity to prepend configuration (method is called in container compilation time)
Use case: