Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Email transport configuration inconsistency #135

Closed
robertpustulka opened this issue Oct 4, 2023 · 1 comment
Closed

Email transport configuration inconsistency #135

robertpustulka opened this issue Oct 4, 2023 · 1 comment
Milestone

Comments

@robertpustulka
Copy link
Member

Docs states that queue transport should be configured like so:

    'EmailTransport' => [
        'queue' => [
            'className' => QueueTransport::class,
            // The transport to use inside the queue job.
            'transport' => MailTransport::class,
            'config' => [
                // Configuration for MailTransport.
            ]
        ]
    ],

Wheras in fact the whole queue array is passed to the transport constructor:

'transport' => $this->getConfig('transport'),
'config' => $this->getConfig(),
'emailMessage' => json_encode($message),

I'd like to fix that the example from docs would work while keeping the existing behavior. For example pass the config array if the key exists and fallback to the whole array thing otherwise.

    protected function prepareData(Message $message): array
    {
        return [
            'transport' => $this->getConfig('transport'),
            'config' => is_array($this->getConfig('config')) ? $this->getConfig('config') : $this->getConfig(),
            'emailMessage' => json_encode($message),
        ];
    }

Also it would be great if you could pass just the name of an already configurated transport, for example:

return [
    // ... other configuration
    'EmailTransport' => [
        'default' => [
            'url' => env('EMAIL_URL'),
        ],
        'queue' => [
            'className' => QueueTransport::class,
            // The transport to use inside the queue job.
            'transport' => 'default',
        ]
    ],
];

I can provide a PR if that sounds reasonable.

@robertpustulka robertpustulka changed the title Queue transport configuration inconsistency Email transport configuration inconsistency Oct 4, 2023
@markstory markstory added this to the 1.0.0 milestone Oct 8, 2023
@markstory
Copy link
Member

Also it would be great if you could pass just the name of an already configurated transport, for example:

This sounds like a great improvement as configuration can be consolidated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants