Note: Playing with Acorn as a plugin in a stock WP install that has a Sage10 theme— no bedrock, no root composer.
I know we’re able to add explicit service providers through the main theme’s config, however it seems backwards to have to do that to add features from a plugin. Since the company uses the Sage10 Parent, with client level child themes, and multiple plugins, for many clients. Where the base Sage10 parent theme can not be used to control all of the plugin views for every plugin added.
In this case, what is the best method of instantiating a plugin with a ServiceProvider? I did not get results adding the provider in “extras” in composer, and wp acorn package:discover
did not list it.
Attempted Solution
I feel like my current implementation is weak but here’s a run down in pseudocode.
ATM I am hooking into the bootstrap filter:
add_filter('acorn/bootstrap', function ($classes) {
return [AddPluginServiceProvider::class] + $classes;
});
Which looks something like:
class AddPluginServiceProvider
public function bootstrap(Application $app)
{
$app->register(new PluginServiceProvider($app));
}
}
Which works and allows me to add my plugin views to the theme’s view list but seems clunky.
Thanks for any tips on improving this solution!
And for visitors from the future, this works with Acorn v2.0.5 and Sage v10.1.4.