jeudi 14 juin 2018

Overriding 2 functions in vendor package class

I'm currently trying to retrieve the SMTP Queue-ID when using the Laravel (5.6) Mail class.

I have copied the file vendor/swiftmailer/swiftmailer/lib/classes/Swift/Transport/AbstractSmtpTransport.php to /app/OverriddenAbstractSmtpTransport.php and made an alias in config/app.php, made my changes:

1: on line#395 I added return in front of the line, so we obtain the output

2: line#492 replaced with $message->queue_ids[] = $this->streamMessage($message);

So I can access queue_ids from the message property in the Illuminate\Mail\Events\MessageSent-event

Now this works, but I don't think it's a very safe approach to modifying the vendor class, as it might cause a breaking change when running security updates.

Is there a simpler/better/safer solution to this ?



from Newest questions tagged laravel-5 - Stack Overflow https://ift.tt/2LRr5lj
via IFTTT

Aucun commentaire:

Enregistrer un commentaire