diff --git a/src/Symfony/Bundle/SwiftmailerBundle/DataCollector/SpoolDataCollector.php b/src/Symfony/Bundle/SwiftmailerBundle/DataCollector/SpoolDataCollector.php new file mode 100644 index 0000000000000..04c622d66efdc --- /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; + +/** + * SpoolDataCollector. + * + * @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 0000000000000..46af5a08795e6 Binary files /dev/null and b/src/Symfony/Bundle/SwiftmailerBundle/Resources/public/images/mail.png differ 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