fabpot/Pimple — pull request #138 by digitalkaoz (2014-06-02 15:19:44+00:00)
Title: added simple compiler pass

this PR adds the ability to register `compiler passes`

its useful to avoid circular references. in my case it was a `EventSubscriber` which needed a Service which needed the `EventDispatcher``

```php

//normal service definitions
$pimple['eventDispatcher'] = function($pimple) {
return new EventDispatcher();
}
$pimple['service'] = function($pimple) {
return new Service($pimple['eventDispatcher']);
}
$pimple['subscriber'] = function($pimple) {
return new Subscriber($pimple['service']);
}

// a direct binding would result in an error:
$pimple->extend('eventDispatcher', function($eventDispatcher, $pimple){
$eventDispatcher->addSubscriber($pimple['subscriber']);
return $eventDispatcher;
});

//lazy subscriber binding, this works:
$pimple->pass(function($pimple){
$pimple['eventDispatcher']->addSubscriber($pimple['subscriber']);
});

//after every is defined, compile the container
$pimple->compile();
```