From 770f1122fb599debf01b014a944db83e91205675 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Jobeili?= Date: Wed, 23 Feb 2011 18:09:47 +0100 Subject: [PATCH 1/2] Add the DataCollector for Swiftmailer Spool --- .../DataCollector/SpoolDataCollector.php | 62 ++++++++++++++++++ .../Resources/config/spool.xml | 6 ++ .../Resources/public/images/mail.png | Bin 0 -> 877 bytes .../Resources/views/Collector/spool.html.twig | 7 ++ 4 files changed, 75 insertions(+) create mode 100644 src/Symfony/Bundle/SwiftmailerBundle/DataCollector/SpoolDataCollector.php create mode 100644 src/Symfony/Bundle/SwiftmailerBundle/Resources/public/images/mail.png create mode 100644 src/Symfony/Bundle/SwiftmailerBundle/Resources/views/Collector/spool.html.twig diff --git a/src/Symfony/Bundle/SwiftmailerBundle/DataCollector/SpoolDataCollector.php b/src/Symfony/Bundle/SwiftmailerBundle/DataCollector/SpoolDataCollector.php new file mode 100644 index 0000000000000..de4dc85d8e0b8 --- /dev/null +++ b/src/Symfony/Bundle/SwiftmailerBundle/DataCollector/SpoolDataCollector.php @@ -0,0 +1,62 @@ + + * + * For the full copyright and license information, please view the LICENSE + * file that was distributed with this source code. + */ + +namespace Symfony\Bundle\SwiftmailerBundle\DataCollector; + +use Symfony\Component\HttpKernel\DataCollector\DataCollector; +use Symfony\Component\HttpFoundation\Request; +use Symfony\Component\HttpFoundation\Response; + +/** + * DoctrineDataCollector. + * + * @author Clément JOBEILI + */ +class SpoolDataCollector extends DataCollector +{ + protected $path; + + public function __construct($path) + { + $this->path = $path; + } + + /** + * {@inheritdoc} + */ + public function collect(Request $request, Response $response, \Exception $exception = null) + { + $messageCount = 0; + + foreach (new \DirectoryIterator($this->path) as $file) { + $file = $file->getRealPath(); + + if (strpos($file, '.message')) { + $messageCount++; + } + } + + $this->data['messageCount'] = $messageCount; + } + + public function getMessageCount() + { + return $this->data['messageCount']; + } + + /** + * {@inheritdoc} + */ + public function getName() + { + return 'spool'; + } +} diff --git a/src/Symfony/Bundle/SwiftmailerBundle/Resources/config/spool.xml b/src/Symfony/Bundle/SwiftmailerBundle/Resources/config/spool.xml index a86c716337c8c..249c62d5a6fad 100644 --- a/src/Symfony/Bundle/SwiftmailerBundle/Resources/config/spool.xml +++ b/src/Symfony/Bundle/SwiftmailerBundle/Resources/config/spool.xml @@ -22,5 +22,11 @@ + + + + %swiftmailer.spool.file.path% + + diff --git a/src/Symfony/Bundle/SwiftmailerBundle/Resources/public/images/mail.png b/src/Symfony/Bundle/SwiftmailerBundle/Resources/public/images/mail.png new file mode 100644 index 0000000000000000000000000000000000000000..46af5a08795e6015dbcc1d895e547e6c1f6de5af GIT binary patch literal 877 zcmV-z1CsoSP)z z&2Ah;5XXPrJ=;6u-OYHtAIwUa69*)G;D8*F2jF7A0uK_#bI_A8zI|L2ois()jd63RbBu3XrropNZ1dm{l73^wzjsueERg; z@A4u?|ISzSWge=mUiaqJtJl9hfBw@CtIeIA-EWGb)PD@$b$EUPf zEn2M>BJywwj6qeoyu2iiV^o>k{BKo-BuU7!jM;3)a5yA{KoF_sJBEmIb#=w*=_%fO zdc7{z+FLY7st`f|3@=~)x)OBm{`jjZB7$=cYpe6Mny+Ws;4^DYJ|2%RA^;H~FLFeL zCtp1QV-OLHxjVihg0*%<(*mC!9UUFi>z?nQJ^L|I)#}zE05E#@j%KsDip5IsAB-(` zmS>DHSZmFAJa!=je61F(JP09RjG@=-F&qw=OeSKvIoO5)$9jtX4 zDHV?*f&$iBvMl4`;)0Wt6E-$B@ZR5J-qi6MFAv$VwYJ|%?(A0iud; z0|u^VQ-YNA`+Y(P{4pLgpU-j5vH9^Ps>*0Iq8`V1?-vYKw5up~e}Dg%?d|Q)cXxL_ zIygA|IgS%Vl%gz{PNqbW<5BAo);Vh4)9rTY_xp6ZU7}hI?>%XnA|WuHOjd=u^u{iF z)J#>cj4?%!z&xK5%0QYvVy)4@T1(^{k#jg}af>-}u39@snx-_HO|IwHU=dq32^R^#CCaNj(n4ZIKj|BwEk--S*4DU-+X00000NkvXXu0mjf D2H2eW literal 0 HcmV?d00001 diff --git a/src/Symfony/Bundle/SwiftmailerBundle/Resources/views/Collector/spool.html.twig b/src/Symfony/Bundle/SwiftmailerBundle/Resources/views/Collector/spool.html.twig new file mode 100644 index 0000000000000..002b5151d0f31 --- /dev/null +++ b/src/Symfony/Bundle/SwiftmailerBundle/Resources/views/Collector/spool.html.twig @@ -0,0 +1,7 @@ +{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %} + +{% block toolbar %} +Spool +{{ collector.messagecount }} + +{% endblock %} \ No newline at end of file From 8f08bf785b00a7fa8683de26701825b748546e69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cle=CC=81ment=20Jobeili?= Date: Wed, 23 Feb 2011 18:11:50 +0100 Subject: [PATCH 2/2] Fix file description --- .../SwiftmailerBundle/DataCollector/SpoolDataCollector.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symfony/Bundle/SwiftmailerBundle/DataCollector/SpoolDataCollector.php b/src/Symfony/Bundle/SwiftmailerBundle/DataCollector/SpoolDataCollector.php index de4dc85d8e0b8..04c622d66efdc 100644 --- a/src/Symfony/Bundle/SwiftmailerBundle/DataCollector/SpoolDataCollector.php +++ b/src/Symfony/Bundle/SwiftmailerBundle/DataCollector/SpoolDataCollector.php @@ -16,7 +16,7 @@ use Symfony\Component\HttpFoundation\Response; /** - * DoctrineDataCollector. + * SpoolDataCollector. * * @author Clément JOBEILI */