Hello,
I'm working on my first big project with Phalcon and I want to use Phaclon\Mailer
from incubator https://github.com/phalcon/incubator/tree/master/Library/Phalcon/Mailer and attach an event to mailer:beforeSend
but it's never reached.
In my public/index.php set eventsManager :
$di = new FactoryDefault();
$di->setShared('eventsManager', function(){
$eventsManager = new EventsManager();
$eventsManager->attach('mailer:beforeSend', function($mailer) {
var_dump($mailer);
die('here');
});
return $eventsManager;
});
etc...
In Phalcon\Mailer\Message.php the send() function get eventsManager with :
$eventManager = $this->getManager()->getEventsManager();
var_dump($eventManger)
: /app/vendor/phalcon/incubator/Library/Phalcon/Mailer/Message.php:634:null
But if I add ->getDi() : $eventManager = $this->getManager()->getDi()->getEventsManager();
my defined eventsManager is good.
I d'ont understand if my eventsManager is wrong registered or something else.
Thanks