-
Notifications
You must be signed in to change notification settings - Fork 129
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
Protected vs private in service provider #303
Comments
I'm kind of against this - I feel you should just override the binding or add a new binding for your version. Willing to be convinced though |
Well, the above code is the only way I managed to be able to extend both FormBuilder and HtmlBuider at the same time. But I may very well have done it the wrong way, and am perfectly willing to be convinced if there is another way. |
You could inside your own service provider bind your version of the Form with the binding of In my mind though, bindings aren't extendable which is why they're private instead of public. It doesn't make sense that bootstrapper::form returns a non-bootstrapper class. I'm currently looking at V6 and how we can support this sort of thing though - I'll keep it in mind |
Yes, I have done this, much simpler indeed. Just need to make sure that my service provider runs after the Boostrapper one. In app.php Bootstrapper\BootstrapperL5ServiceProvider::class,
App\Providers\AppServiceProvider::class, In app/Providers/AppServiceProvider.php /**
* Register the HTML builder instance.
*
* @return void
*/
protected function registerHtmlBuilder()
{
$this->app->bindShared('html', function ($app) {
return new \App\Services\HtmlBuilder($app['url']);
});
}
/**
* Register the form builder instance.
*
* @return void
*/
protected function registerFormBuilder()
{
$this->app->bindShared('illuminate::html',function ($app) {
return new \Illuminate\Html\HtmlBuilder($app->make('url'));
}
);
$this->app->bindShared('bootstrapper::form',function ($app) {
$form = new \App\Services\FormBuilder(
$app->make('illuminate::html'),
$app->make('url'),
$app['session.store']->getToken()
);
return $form->setSessionStore($app['session.store']);
},
true
);
} In app/Services/HtmlBuilder.php class HtmlBuilder extends \Collective\Html\HtmlBuilder { ... } In app/Services/FormBuilder.php class FormBuilder extends \Bootstrapper\Form { ... } Thank you! |
Would it be possible to set all the methods from
BootstrapperL5ServiceProvider
to be protected instead of private?If so, we can then extend the service provider with something like this:
alongside this:
The text was updated successfully, but these errors were encountered: