Można utworzyć kernel.request
zdarzeń słuchacza, wstrzyknąć swiftmailer.transport.real
i zestaw informacji SMTP np
Listener klasy
namespace Namespace\Of\YourListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
class YourListener implements EventSubscriberInterface
{
/**
* @var Swift_Transport_EsmtpTransport
*/
private $transport;
/**
* @var Doctrine\ORM\EntityManager
*/
private $em;
public function __construct($transport, $em)
{
$this->transport = $transport;
$this->em = $em;
}
public function onKernelRequest(GetResponseEvent $event)
{
//fetch info from db
$this->transport->setHost("host");
$this->transport->setPort("port");
$this->transport->setUserName("username");
$this->transport->setPassword("pass");
}
static public function getSubscribedEvents()
{
return array(
KernelEvents::REQUEST => array('onKernelRequest', 0)
);
}
}
usługi decleration,
your_listener:
class: FQCN\Of\YourListener
tags:
- { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }
arguments: [@swiftmailer.transport.real, @doctrine.orm.entity_manager]
Jestem tylko ciekaw, jak można przechowywać hasła? – Gigala
@Gigala Widzę, co tam zrobiłeś. Tak, na to pytanie trzeba odpowiedzieć! – aalaap
@aalaap haha to mój stary komentarz: P – Gigala