sampart / WhiteOctoberSwiftMailerDBBundle

A bundle to facilitate SwiftMailer spooling messages to a database
31 stars 18 forks source link

Make object manager configurable #21

Closed dpk125 closed 7 years ago

dpk125 commented 7 years ago

This allows to define separate doctrine entity manager for emails, so when we're flushing spool to the database, only Email entities will be flushed.

Sample doctrine configuration:

doctrine:
    orm:
        entity_managers:
            default:
                connection: default
                auto_mapping: true
            mail:
                connection: default
                mappings:
                    MailBundle: ~
sampart commented 7 years ago

Thanks for the PR, @dpk125. This may be a silly question, but I'm wondering whether a simpler approach would be to update the existing calls to flush so that $mailObject is passed in - that way only that object will be flushed, without the need for extra config. What do you think?

dpk125 commented 7 years ago

There are plans to drop support for flushing a single entity: https://github.com/doctrine/doctrine2/issues/6118

https://github.com/andreia/awesome-doctrine/pull/1

sampart commented 7 years ago

Thanks for clarifying. In that case, this approach looks very sensible. Please can you update the documentation to show that this is supported (e.g. with a config example like the one in your PR) and then I'll merge. Thanks!

sampart commented 7 years ago

Thanks for your work here, @dpk125! I've merged this now as you'll see. Sorry for the delay in merging - I didn't see an alert that you'd updated your commit (perhaps because it was an update rather than a new commit) so have only just seen this.

Do you need a release for this or can it wait until we're next doing a release anyway?

dpk125 commented 7 years ago

@sampart It would be nice to have a new release for this :)

sampart commented 7 years ago

@dpk125 your wish is my command: https://github.com/whiteoctober/WhiteOctoberSwiftMailerDBBundle/releases/tag/1.1.0 :smiley:

dpk125 commented 7 years ago

Awesome, thanks!