Wind Waker
Wind Waker

Reputation: 13

Get Swiftmailer's settings from a Controller in Symfony2

I have this config in my config.yml file

swiftmailer:
    transport: "%mailer_transport%"
    host:      "%mailer_host%"
    username:  "%mailer_user%"
    password:  "%mailer_password%"
    spool:     { type: memory }

How do I read these settings from a controller in order to check whether spool has been set or not?

Upvotes: 0

Views: 398

Answers (1)

Victor Bocharsky
Victor Bocharsky

Reputation: 12306

You could move spool config in parameters.yml, for example:

# app/config/parameters.yml
parameters:
    mailer_spool: { type: memory }

And then replace this line in config.yml with parameter:

# app/config/config.yml
swiftmailer:
    spool: "%mailer_spool%"

Now in any controller you could get this spool config like:

public function yourAction()
{
    $spool = $this->getParameter('mailer_spool');
}

Upvotes: 1

Related Questions