groupe-sii / ogham

Sending email, sms or whatever is a piece of cake
https://groupe-sii.github.io/ogham/
Apache License 2.0
21 stars 14 forks source link

Simplify access specific builders #89

Open aurelien-baudet opened 4 years ago

aurelien-baudet commented 4 years ago

Currently developer must know about Builder classes to chain and configure:

MessagingBuilder.standard()
  .email()
    .sender(JavaMailBuilder.class)
      .host("localhost")

There should be direct access to well-known senders and template engines:

MessagingBuilder.standard()
  .email()
    .javamail()
     .host("localhost")

The issue with this behavior is that core knows about all other modules (core should be agnostic about possible implementations) and it can't be compiled due to cyclic dependencies (javamail() method should provide a way to find the right builder that works even after refactoring code of JavaMail module).

Another possibility is simply to "centralize" all builders in ogham-all module:

MessagingBuilder.standard()
  .email()
    .sender(OghamSenders.javamail())
      .host("localhost")

However, if we don't use ogham-all module, we won't benefit from this helper.