I'm trying to implement interface injection
with Silex\Application
.
I have my bootstrapping in one PHP file, mind, this is simplified without the interfaces actually:
$app = new Silex\Application();
$app->register(
new ServiceProvider($app)
);
$app['testme'] = function() {
throw new Exception('I am invoked');
};
$app->run();
And I have the ServiceProvider:
class ServiceProvider implements ServiceProviderInterface
{
public function register(Application $app) {
foreach ($app as $key => $val) {
if ($key == 'testme') {
throw new Exception('it works!');
}
}
}
}
The first exception should not be thrown but I expected the second one to trigger.
Why does the above not work and where might be the spot in silex to inject configuration into interfaces according to $app[....] instanceof MyAwareInterface
?