koriym/Ray.Di — pull request #92 by koriym (2014-12-09 10:41:49+00:00)
Title: AbstractModule::rename(($interface, $newName)

You can re-bind exiting bound with `AbstractModule::rename()`

Example

```php
class WebRouterModule extends AbstractModule
{
protected function configure()
{
$this->bind(RouterInterface::class)->to(WebRouter::class);
}
}
```

```php
class AuraRouterModule extends AbstractModule
{
protected function configure()
{
$this->rename(RouterInterface::class, 'original');
$this->bind(RouterInterface::class)->to(AuraRouter::class);
}
}
```

```php
class AuraRouter implements RouterInterface
{
/**
* @Inject
* @Named("original")
*/
public function __construct(RouterInterface $router)
{
....
```
### dependency graph

#### before:

```php
$logger = (new Injector(new WebRouterModule)->getInstance(LoggerInterface::class); // WebRouter
```
consumer → < RouterInterface:`*` > → **WebRouter**

#### after with **rename()** method

```php
$logger = (new Injector(new AuraRouterModule(new WebRouterModule))->getInstance(LoggerInterface::class); // AuraRouter
```
consumer → < RouterInterface:`*` > → **AuraRouter** →< RouterInterface:`original` > → **WebRouter**