Ticket #97 (closed enhancement: fixed)

Opened 10 months ago

Last modified 7 months ago

Give injection provider more informations about requested injection

Reported by: mikey Assigned to: mikey
Priority: major Milestone: 0.6.0
Component: InversionOfControl Version: SVN-trunk
Keywords: Cc:

Description

I would like to have more information available inside an injection provider to allow the provider to decide which implementation (or concrete instance) to return. Consider the following:

$binder->bind('stubDatabaseConnection')->named('downloads')->toProvider(new DatabaseConnectionProvider('downloads'));
$binder->bind('stubDatabaseConnection')->named('press')->toProvider(new DatabaseConnectionProvider('press'));
$binder->bind('stubDatabaseConnection')->named('jobs')->toProvider(new DatabaseConnectionProvider('jobs'));

In this example you need several provider instances, one for each named injection. If the provider would know itself about the named annotation it could decide itself what to return. This would keep the amount of bindings lower, and one would only need one provider instance instead of several ones.

Change History

11/14/07 18:46:03 changed by schst

  • status changed from new to assigned.
  • milestone set to 0.4.0.

11/28/07 15:43:17 changed by mikey

  • milestone changed from 0.4.0 to 0.5.0.

01/11/08 10:10:54 changed by mikey

  • milestone changed from 0.5.0 to 0.6.0.

02/21/08 17:13:39 changed by mikey

  • owner changed from schst to mikey.
  • status changed from assigned to new.

02/21/08 17:13:46 changed by mikey

  • status changed from new to assigned.

02/21/08 17:22:08 changed by mikey

Some thoughts for the refactoring:

- Scopes and bindings only return injection providers instead of concrete instances to inject. - Injector gets instance from injection provider, which in turn it gets from the binding.

02/25/08 18:58:31 changed by mikey

Implemented with r1370.

Todo: Increase test coverage, not all use cases are covered. Todo: Update documentation.

02/25/08 23:28:02 changed by mikey

  • status changed from assigned to closed.
  • resolution set to fixed.

Test cases added with r1371, documentation was updated as well.