I'm trying to add an event listener/dispatcher to one of my controller action. It's goal is to add default data to my entity before persisting it in my database.
Here is what I've got so far.
app.php
$app['dispatcher']->addListener('my_event_name', function (Event $event) {
// do something;
});
It ends up with the following error :
( ! ) InvalidArgumentException: Identifier "dispatcher" does not contain an object definition. in /var/www/site/vendor/pimple/pimple/src/Pimple/Container.php on line 233
Check out this thread. Looks like it has to do with a precise order in which you call and initialize.
https://github.com/silexphp/Silex-WebProfiler/issues/70#issuecomment-170399805