├── .gitignore ├── CHANGELOG.md ├── DataCollector └── MessageDataCollector.php ├── LICENSE └── composer.json /.gitignore: -------------------------------------------------------------------------------- 1 | vendor/ 2 | composer.lock 3 | phpunit.xml 4 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | CHANGELOG 2 | ========= 3 | 4 | 2.1.0 5 | ----- 6 | 7 | * added a data collector 8 | -------------------------------------------------------------------------------- /DataCollector/MessageDataCollector.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Symfony\Bridge\Swiftmailer\DataCollector; 13 | 14 | use Symfony\Component\HttpKernel\DataCollector\DataCollector; 15 | use Symfony\Component\HttpFoundation\Request; 16 | use Symfony\Component\HttpFoundation\Response; 17 | use Symfony\Component\DependencyInjection\ContainerInterface; 18 | 19 | /** 20 | * MessageDataCollector. 21 | * 22 | * @author Fabien Potencier 23 | * @author Clément JOBEILI 24 | * 25 | * @deprecated Deprecated since version 2.4, to be removed in 3.0. Use 26 | * MessageDataCollector of SwiftmailerBundle instead. 27 | */ 28 | class MessageDataCollector extends DataCollector 29 | { 30 | private $container; 31 | private $isSpool; 32 | 33 | /** 34 | * Constructor. 35 | * 36 | * We don't inject the message logger and mailer here 37 | * to avoid the creation of these objects when no emails are sent. 38 | * 39 | * @param ContainerInterface $container A ContainerInterface instance 40 | * @param bool $isSpool 41 | */ 42 | public function __construct(ContainerInterface $container, $isSpool) 43 | { 44 | $this->container = $container; 45 | $this->isSpool = $isSpool; 46 | } 47 | 48 | /** 49 | * {@inheritdoc} 50 | */ 51 | public function collect(Request $request, Response $response, \Exception $exception = null) 52 | { 53 | // only collect when Swiftmailer has already been initialized 54 | if (class_exists('Swift_Mailer', false)) { 55 | $logger = $this->container->get('swiftmailer.plugin.messagelogger'); 56 | $this->data['messages'] = $logger->getMessages(); 57 | $this->data['messageCount'] = $logger->countMessages(); 58 | } else { 59 | $this->data['messages'] = array(); 60 | $this->data['messageCount'] = 0; 61 | } 62 | 63 | $this->data['isSpool'] = $this->isSpool; 64 | } 65 | 66 | public function getMessageCount() 67 | { 68 | return $this->data['messageCount']; 69 | } 70 | 71 | public function getMessages() 72 | { 73 | return $this->data['messages']; 74 | } 75 | 76 | public function isSpool() 77 | { 78 | return $this->data['isSpool']; 79 | } 80 | 81 | /** 82 | * {@inheritdoc} 83 | */ 84 | public function getName() 85 | { 86 | return 'swiftmailer'; 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2014 Fabien Potencier 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "symfony/swiftmailer-bridge", 3 | "type": "symfony-bridge", 4 | "description": "Symfony Swiftmailer Bridge", 5 | "keywords": [], 6 | "homepage": "http://symfony.com", 7 | "license": "MIT", 8 | "authors": [ 9 | { 10 | "name": "Fabien Potencier", 11 | "email": "fabien@symfony.com" 12 | }, 13 | { 14 | "name": "Symfony Community", 15 | "homepage": "http://symfony.com/contributors" 16 | } 17 | ], 18 | "require": { 19 | "php": ">=5.3.3", 20 | "swiftmailer/swiftmailer": ">=4.2.0,<6.0-dev" 21 | }, 22 | "suggest": { 23 | "symfony/http-kernel": "" 24 | }, 25 | "autoload": { 26 | "psr-0": { "Symfony\\Bridge\\Swiftmailer\\": "" } 27 | }, 28 | "target-dir": "Symfony/Bridge/Swiftmailer", 29 | "minimum-stability": "dev", 30 | "extra": { 31 | "branch-alias": { 32 | "dev-master": "3.0-dev" 33 | } 34 | } 35 | } 36 | --------------------------------------------------------------------------------