Ticket #188 (closed enhancement: wontfix)
Allow binding with annotations
| Reported by: | mikey | Owned by: | mikey |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | InversionOfControl | Version: | SVN-trunk |
| Keywords: | Cc: |
Description
The injection container should allow to bind something based on an annotation. Example
class Foo
/**
* @Inject
* @Dummy
*/
public function setBar(Bar $bar) { ... }
...
}
$binder->bind('Bar')->to('DefaultBar');
$binder->bind('Bar')->annotatedWith('Dummy')->to('DummyBar');
This will inject DefaultBar instances to methods not annotated with @Dummy, and DummyBar instances to methods annotated with @Dummy. It is kind of similar to the @Named annotations, so I'm currently not seeing any real usecase for this, though. I just wanted to note the idea like seen in Google Guide, so it gets a low priority.
Change History
Note: See
TracTickets for help on using
tickets.
