framework icon indicating copy to clipboard operation
framework copied to clipboard

Contextual Binding Not Working

Open mixnetworks opened this issue 11 years ago • 2 comments

I'm defining a contextual binding within a Service Provider like so: $this->app->when('Sky\Service')->needs('Sky\Interface')->give(function() { return Setting::get('carrier.voip360'); // I'm expecting this to be called });

I'm defining a default binding like so: $this->app->singleton('Sky\Interface', function() { return Setting::get('carrier.starnet'); // this is unexpectedly called });

I'm then define the instantiation of class which SHOULD use the contextual binding but does not $this->app->singleton('Sky\Service', function() { return new \Sky\Carrier\Starnet\Service( $this->app->make('Illuminate\Contracts\Logging\Log'), $this->app['cache']->driver(), $this->app->make('Sky\Interface') ); });

I've tracked the issue through to \Illuminate\Container\Container@getContextualConcrete. It seems that this method is expecting the last item in Container->buildStack to be 'Sky\Service' but it is not. It does not seem like Container->buildStack is getting updated properly.

mixnetworks avatar May 12 '15 22:05 mixnetworks

We're open to PRs.

GrahamCampbell avatar May 31 '15 18:05 GrahamCampbell

does it make sense to acknowledge a bug in a ticket and close it? Wouldn't it make sense to keep the ticket open to acknowledge an issue until it can be fixed, maybe by a pull request?

ghost avatar Jun 01 '15 19:06 ghost