Change Message sent text to Message spooled if we are in a spool context

This commit is contained in:
Clément Jobeili 2011-03-21 09:01:50 +01:00
parent a505ff43b5
commit f8dead7782
2 changed files with 12 additions and 6 deletions

View File

@ -24,12 +24,12 @@ use Symfony\Component\HttpFoundation\Response;
class MessageDataCollector extends DataCollector
{
protected $logger;
protected $mailer;
public function __construct(\Swift_Events_SendListener $logger, \Swift_Mailer $mailer)
{
$this->logger = $logger;
// we do nothing with the mailer
// it's in the constructor just to force SwiftMailer to be initialized
$this->mailer = $mailer;
}
/**
@ -37,8 +37,9 @@ class MessageDataCollector extends DataCollector
*/
public function collect(Request $request, Response $response, \Exception $exception = null)
{
$this->data['messages'] = $this->logger->getMessages();
$this->data['messages'] = $this->logger->getMessages();
$this->data['messageCount'] = $this->logger->countMessages();
$this->data['isSpool'] = $this->mailer->getTransport() instanceof \Swift_Transport_SpoolTransport;
}
public function getMessageCount()
@ -50,6 +51,11 @@ class MessageDataCollector extends DataCollector
{
return $this->data['messages'];
}
public function isSpool()
{
return $this->data['isSpool'];
}
/**
* {@inheritdoc}
@ -58,4 +64,4 @@ class MessageDataCollector extends DataCollector
{
return 'swiftmailer';
}
}
}

View File

@ -23,7 +23,7 @@
{% endblock %}
{% block panel %}
<h2>Messages sent</h2>
<h2>Messages {% if not collector.isSpool %} sent {% else %} spooled {% endif %}</h2>
{% if not collector.messages %}
<p>