Initial commit with Symfony 2.1+Vendors

Signed-off-by: Gergely POLONKAI (W00d5t0ck) <polesz@w00d5t0ck.info>
This commit is contained in:
Polonkai Gergely
2012-07-01 09:52:20 +02:00
commit 082a0130c2
5381 changed files with 416709 additions and 0 deletions

View File

@@ -0,0 +1,74 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\SwiftmailerBundle\Command;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Input\InputOption;
/**
* Send Emails from the spool.
*
* @author Fabien Potencier <fabien@symfony.com>
* @author Clément JOBEILI <clement.jobeili@gmail.com>
*/
class SendEmailCommand extends ContainerAwareCommand
{
/**
* @see Command
*/
protected function configure()
{
$this
->setName('swiftmailer:spool:send')
->setDescription('Sends emails from the spool')
->addOption('message-limit', 0, InputOption::VALUE_OPTIONAL, 'The maximum number of messages to send.')
->addOption('time-limit', 0, InputOption::VALUE_OPTIONAL, 'The time limit for sending messages (in seconds).')
->addOption('recover-timeout', 0, InputOption::VALUE_OPTIONAL, 'The timeout for recovering messages that have taken too long to send (in seconds).')
->setHelp(<<<EOF
The <info>swiftmailer:spool:send</info> command sends all emails from the spool.
<info>php app/console swiftmailer:spool:send --message-limit=10 --time-limit=10 --recover-timeout=900</info>
EOF
)
;
}
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
$mailer = $this->getContainer()->get('mailer');
$transport = $mailer->getTransport();
if ($transport instanceof \Swift_Transport_SpoolTransport) {
$spool = $transport->getSpool();
if ($spool instanceof \Swift_ConfigurableSpool) {
$spool->setMessageLimit($input->getOption('message-limit'));
$spool->setTimeLimit($input->getOption('time-limit'));
}
if ($spool instanceof \Swift_FileSpool) {
if (null !== $input->getOption('recover-timeout')) {
$spool->recover($input->getOption('recover-timeout'));
} else {
$spool->recover();
}
}
$sent = $spool->flushQueue($this->getContainer()->get('swiftmailer.transport.real'));
$output->writeln(sprintf('sent %s emails', $sent));
}
}
}

View File

@@ -0,0 +1,36 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\SwiftmailerBundle\DependencyInjection\Compiler;
use Symfony\Component\DependencyInjection\Reference;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
/**
* RegisterPluginsPass registers Swiftmailer plugins.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class RegisterPluginsPass implements CompilerPassInterface
{
public function process(ContainerBuilder $container)
{
if (!$container->hasDefinition('swiftmailer.mailer')) {
return;
}
$definition = $container->findDefinition('swiftmailer.transport');
foreach ($container->findTaggedServiceIds('swiftmailer.plugin') as $id => $args) {
$definition->addMethodCall('registerPlugin', array(new Reference($id)));
}
}
}

View File

@@ -0,0 +1,91 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\SwiftmailerBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
/**
* This class contains the configuration information for the bundle
*
* This information is solely responsible for how the different configuration
* sections are normalized, and merged.
*
* @author Christophe Coevoet <stof@notk.org>
*/
class Configuration implements ConfigurationInterface
{
private $debug;
/**
* Constructor.
*
* @param Boolean $debug The kernel.debug value
*/
public function __construct($debug)
{
$this->debug = (Boolean) $debug;
}
/**
* Generates the configuration tree builder.
*
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder
*/
public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('swiftmailer');
$rootNode
->children()
->scalarNode('transport')->defaultValue('smtp')->end()
->scalarNode('username')->defaultNull()->end()
->scalarNode('password')->defaultNull()->end()
->scalarNode('host')->defaultValue('localhost')->end()
->scalarNode('port')->defaultFalse()->end()
->scalarNode('encryption')
->defaultNull()
->validate()
->ifNotInArray(array('tls', 'ssl', null))
->thenInvalid('The %s encryption is not supported')
->end()
->end()
->scalarNode('auth_mode')
->defaultNull()
->validate()
->ifNotInArray(array('plain', 'login', 'cram-md5', null))
->thenInvalid('The %s authentication mode is not supported')
->end()
->end()
->arrayNode('spool')
->children()
->scalarNode('type')->defaultValue('file')->end()
->scalarNode('path')->defaultValue('%kernel.cache_dir%/swiftmailer/spool')->end()
->end()
->end()
->scalarNode('sender_address')->end()
->arrayNode('antiflood')
->children()
->scalarNode('threshold')->defaultValue(99)->end()
->scalarNode('sleep')->defaultValue(0)->end()
->end()
->end()
->scalarNode('delivery_address')->end()
->booleanNode('disable_delivery')->end()
->booleanNode('logging')->defaultValue($this->debug)->end()
->end()
;
return $treeBuilder;
}
}

View File

@@ -0,0 +1,155 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\SwiftmailerBundle\DependencyInjection;
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\Config\FileLocator;
/**
* SwiftmailerExtension is an extension for the SwiftMailer library.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class SwiftmailerExtension extends Extension
{
/**
* Loads the Swift Mailer configuration.
*
* Usage example:
*
* <swiftmailer:config transport="gmail">
* <swiftmailer:username>fabien</swift:username>
* <swiftmailer:password>xxxxx</swift:password>
* <swiftmailer:spool path="/path/to/spool/" />
* </swiftmailer:config>
*
* @param array $configs An array of configuration settings
* @param ContainerBuilder $container A ContainerBuilder instance
*/
public function load(array $configs, ContainerBuilder $container)
{
$loader = new XmlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
$loader->load('swiftmailer.xml');
$container->setAlias('mailer', 'swiftmailer.mailer');
$configuration = $this->getConfiguration($configs, $container);
$config = $this->processConfiguration($configuration, $configs);
if (null === $config['transport']) {
$transport = 'null';
} elseif ('gmail' === $config['transport']) {
$config['encryption'] = 'ssl';
$config['auth_mode'] = 'login';
$config['host'] = 'smtp.gmail.com';
$transport = 'smtp';
} else {
$transport = $config['transport'];
}
if (isset($config['disable_delivery']) && $config['disable_delivery']) {
$transport = 'null';
}
if ('smtp' === $transport) {
$loader->load('smtp.xml');
}
if (in_array($transport, array('smtp', 'mail', 'sendmail', 'null'))) {
// built-in transport
$transport = 'swiftmailer.transport.'.$transport;
}
$container->setAlias('swiftmailer.transport', $transport);
if (false === $config['port']) {
$config['port'] = 'ssl' === $config['encryption'] ? 465 : 25;
}
foreach (array('encryption', 'port', 'host', 'username', 'password', 'auth_mode') as $key) {
$container->setParameter('swiftmailer.transport.smtp.'.$key, $config[$key]);
}
// spool?
if (isset($config['spool'])) {
$type = $config['spool']['type'];
$loader->load('spool.xml');
if ($type === 'file') {
$loader->load('spool_file.xml');
} elseif ($type === 'memory') {
$loader->load('spool_memory.xml');
}
$container->setAlias('swiftmailer.transport.real', $transport);
$container->setAlias('swiftmailer.transport', 'swiftmailer.transport.spool');
$container->setAlias('swiftmailer.spool', 'swiftmailer.spool.'.$type);
foreach (array('path') as $key) {
$container->setParameter('swiftmailer.spool.'.$type.'.'.$key, $config['spool'][$key]);
}
}
$container->setParameter('swiftmailer.spool.enabled', isset($config['spool']));
// antiflood?
if (isset($config['antiflood'])) {
$container->setParameter('swiftmailer.plugin.antiflood.threshold', $config['antiflood']['threshold']);
$container->setParameter('swiftmailer.plugin.antiflood.sleep', $config['antiflood']['sleep']);
$container->getDefinition('swiftmailer.plugin.antiflood')->addTag('swiftmailer.plugin');
}
if ($config['logging']) {
$container->getDefinition('swiftmailer.plugin.messagelogger')->addTag('swiftmailer.plugin');
$container->findDefinition('swiftmailer.data_collector')->addTag('data_collector', array('template' => 'SwiftmailerBundle:Collector:swiftmailer', 'id' => 'swiftmailer'));
}
if (isset($config['sender_address']) && $config['sender_address']) {
$container->setParameter('swiftmailer.sender_address', $config['sender_address']);
$container->getDefinition('swiftmailer.plugin.impersonate')->addTag('swiftmailer.plugin');
} else {
$container->setParameter('swiftmailer.sender_address', null);
}
if (isset($config['delivery_address']) && $config['delivery_address']) {
$container->setParameter('swiftmailer.single_address', $config['delivery_address']);
$container->getDefinition('swiftmailer.plugin.redirecting')->addTag('swiftmailer.plugin');
} else {
$container->setParameter('swiftmailer.single_address', null);
}
}
/**
* Returns the base path for the XSD files.
*
* @return string The XSD base path
*/
public function getXsdValidationBasePath()
{
return __DIR__.'/../Resources/config/schema';
}
/**
* Returns the namespace to be used for this extension (XML namespace).
*
* @return string The XML namespace
*/
public function getNamespace()
{
return 'http://symfony.com/schema/dic/swiftmailer';
}
public function getConfiguration(array $config, ContainerBuilder $container)
{
return new Configuration($container->getParameter('kernel.debug'));
}
}

View File

@@ -0,0 +1,59 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\SwiftmailerBundle\EventListener;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\IntrospectableContainerInterface;
use Symfony\Component\HttpKernel\Event\PostResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
/**
* Sends emails for the memory spool.
*
* Emails are sent on the kernel.terminate event.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class EmailSenderListener implements EventSubscriberInterface
{
private $container;
public function __construct(ContainerInterface $container, $autoStart = false)
{
$this->container = $container;
}
public function onKernelTerminate(PostResponseEvent $event)
{
if ($this->container instanceof IntrospectableContainerInterface && !$this->container->initialized('mailer')) {
return;
}
$transport = $this->container->get('mailer')->getTransport();
if (!$transport instanceof \Swift_Transport_SpoolTransport) {
return;
}
$spool = $transport->getSpool();
if (!$spool instanceof \Swift_MemorySpool) {
return;
}
$spool->flushQueue($this->container->get('swiftmailer.transport.real'));
}
static public function getSubscribedEvents()
{
return array(KernelEvents::TERMINATE => 'onKernelTerminate');
}
}

View File

@@ -0,0 +1,19 @@
Copyright (c) 2004-2012 Fabien Potencier
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is furnished
to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="UTF-8" ?>
<xsd:schema xmlns="http://symfony.com/schema/dic/swiftmailer"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://symfony.com/schema/dic/swiftmailer"
elementFormDefault="qualified">
<xsd:element name="config" type="config" />
<xsd:complexType name="config">
<xsd:all>
<xsd:element name="spool" type="spool" minOccurs="0" maxOccurs="1" />
<xsd:element name="antiflood" type="antiflood" minOccurs="0" maxOccurs="1" />
</xsd:all>
<xsd:attribute name="username" type="xsd:string" />
<xsd:attribute name="password" type="xsd:string" />
<xsd:attribute name="host" type="xsd:string" />
<xsd:attribute name="port" type="xsd:string" />
<xsd:attribute name="encryption" type="encryption" />
<xsd:attribute name="auth-mode" type="auth_mode" />
<xsd:attribute name="transport" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="delivery-address" type="xsd:string" />
<xsd:attribute name="disable-delivery" type="xsd:boolean" />
<xsd:attribute name="sender-address" type="xsd:boolean" />
<xsd:attribute name="logging" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="spool">
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="path" type="xsd:string" />
</xsd:complexType>
<xsd:complexType name="antiflood">
<xsd:attribute name="threshold" type="xsd:string" />
<xsd:attribute name="sleep" type="xsd:string" />
</xsd:complexType>
<xsd:simpleType name="encryption">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="tls" />
<xsd:enumeration value="ssl" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="auth_mode">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="plain" />
<xsd:enumeration value="login" />
<xsd:enumeration value="cram-md5" />
</xsd:restriction>
</xsd:simpleType>
<xsd:simpleType name="delivery_strategy">
<xsd:restriction base="xsd:string">
<xsd:enumeration value="realtime" />
<xsd:enumeration value="spool" />
<xsd:enumeration value="single-address" />
<xsd:enumeration value="none" />
</xsd:restriction>
</xsd:simpleType>
</xsd:schema>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="swiftmailer.transport.smtp.class">Swift_Transport_EsmtpTransport</parameter>
</parameters>
<services>
<service id="swiftmailer.transport.smtp" class="%swiftmailer.transport.smtp.class%" public="false">
<argument type="service" id="swiftmailer.transport.buffer" />
<argument type="collection">
<argument type="service" id="swiftmailer.transport.authhandler" />
</argument>
<argument type="service" id="swiftmailer.transport.eventdispatcher" />
<call method="setHost"><argument>%swiftmailer.transport.smtp.host%</argument></call>
<call method="setPort"><argument>%swiftmailer.transport.smtp.port%</argument></call>
<call method="setEncryption"><argument>%swiftmailer.transport.smtp.encryption%</argument></call>
<call method="setUsername"><argument>%swiftmailer.transport.smtp.username%</argument></call>
<call method="setPassword"><argument>%swiftmailer.transport.smtp.password%</argument></call>
<call method="setAuthMode"><argument>%swiftmailer.transport.smtp.auth_mode%</argument></call>
</service>
</services>
</container>

View File

@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="swiftmailer.plugin.redirecting.class">Swift_Plugins_RedirectingPlugin</parameter>
<parameter key="swiftmailer.plugin.blackhole.class">Swift_Plugins_BlackholePlugin</parameter>
</parameters>
<services>
<service id="swiftmailer.transport.spool" class="Swift_Transport_SpoolTransport" public="false">
<argument type="service" id="swiftmailer.transport.eventdispatcher" />
<argument type="service" id="swiftmailer.spool" />
</service>
</services>
</container>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="swiftmailer.spool.file.class">Swift_FileSpool</parameter>
</parameters>
<services>
<service id="swiftmailer.spool.file" class="%swiftmailer.spool.file.class%" public="false">
<argument>%swiftmailer.spool.file.path%</argument>
</service>
</services>
</container>

View File

@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="swiftmailer.spool.memory.class">Swift_MemorySpool</parameter>
<parameter key="swiftmailer.email_sender.listener.class">Symfony\Bundle\SwiftmailerBundle\EventListener\EmailSenderListener</parameter>
</parameters>
<services>
<service id="swiftmailer.spool.memory" class="%swiftmailer.spool.memory.class%" public="false" />
<service id="swiftmailer.email_sender.listener" class="%swiftmailer.email_sender.listener.class%">
<tag name="kernel.event_subscriber" />
<argument type="service" id="service_container" />
</service>
</services>
</container>

View File

@@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8" ?>
<container xmlns="http://symfony.com/schema/dic/services"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd">
<parameters>
<parameter key="swiftmailer.class">Swift_Mailer</parameter>
<parameter key="swiftmailer.transport.sendmail.class">Swift_Transport_SendmailTransport</parameter>
<parameter key="swiftmailer.transport.mail.class">Swift_Transport_MailTransport</parameter>
<parameter key="swiftmailer.transport.failover.class">Swift_Transport_FailoverTransport</parameter>
<parameter key="swiftmailer.plugin.redirecting.class">Swift_Plugins_RedirectingPlugin</parameter>
<parameter key="swiftmailer.plugin.impersonate.class">Swift_Plugins_ImpersonatePlugin</parameter>
<parameter key="swiftmailer.plugin.messagelogger.class">Swift_Plugins_MessageLogger</parameter>
<parameter key="swiftmailer.plugin.antiflood.class">Swift_Plugins_AntiFloodPlugin</parameter>
<parameter key="swiftmailer.plugin.antiflood.threshold">99</parameter>
<parameter key="swiftmailer.plugin.antiflood.sleep">0</parameter>
<parameter key="swiftmailer.data_collector.class">Symfony\Bridge\Swiftmailer\DataCollector\MessageDataCollector</parameter>
</parameters>
<services>
<service id="swiftmailer.mailer" class="%swiftmailer.class%" public="false">
<argument type="service" id="swiftmailer.transport" />
</service>
<service id="swiftmailer.transport.sendmail" class="%swiftmailer.transport.sendmail.class%" public="false">
<argument type="service" id="swiftmailer.transport.buffer" />
<argument type="service" id="swiftmailer.transport.eventdispatcher" />
</service>
<service id="swiftmailer.transport.mail" class="%swiftmailer.transport.mail.class%" public="false">
<argument type="service" id="swiftmailer.transport.mailinvoker" />
<argument type="service" id="swiftmailer.transport.eventdispatcher" />
</service>
<service id="swiftmailer.transport.failover" class="%swiftmailer.transport.failover.class%" public="false" />
<service id="swiftmailer.transport.mailinvoker" class="Swift_Transport_SimpleMailInvoker" public="false" />
<service id="swiftmailer.transport.buffer" class="Swift_Transport_StreamBuffer" public="false">
<argument type="service" id="swiftmailer.transport.replacementfactory" />
</service>
<service id="swiftmailer.transport.authhandler" class="Swift_Transport_Esmtp_AuthHandler" public="false">
<argument type="collection">
<argument type="service"><service class="Swift_Transport_Esmtp_Auth_CramMd5Authenticator" public="false" /></argument>
<argument type="service"><service class="Swift_Transport_Esmtp_Auth_LoginAuthenticator" public="false" /></argument>
<argument type="service"><service class="Swift_Transport_Esmtp_Auth_PlainAuthenticator" public="false" /></argument>
</argument>
</service>
<service id="swiftmailer.transport.eventdispatcher" class="Swift_Events_SimpleEventDispatcher" public="false" />
<service id="swiftmailer.transport.replacementfactory" class="Swift_StreamFilters_StringReplacementFilterFactory" public="false" />
<service id="swiftmailer.transport.null" class="Swift_Transport_NullTransport" public="false">
<argument type="service" id="swiftmailer.transport.eventdispatcher" />
</service>
<service id="swiftmailer.plugin.redirecting" class="%swiftmailer.plugin.redirecting.class%" public="false">
<argument>%swiftmailer.single_address%</argument>
</service>
<service id="swiftmailer.plugin.antiflood" class="%swiftmailer.plugin.antiflood.class%" public="false">
<argument>%swiftmailer.plugin.antiflood.threshold%</argument>
<argument>%swiftmailer.plugin.antiflood.sleep%</argument>
</service>
<service id="swiftmailer.plugin.impersonate" class="%swiftmailer.plugin.impersonate.class%" public="false">
<argument>%swiftmailer.sender_address%</argument>
</service>
<service id="swiftmailer.plugin.messagelogger" class="%swiftmailer.plugin.messagelogger.class%" />
<service id="swiftmailer.data_collector" class="%swiftmailer.data_collector.class%" public="false">
<argument type="service" id="service_container" />
<argument>%swiftmailer.spool.enabled%</argument>
</service>
<service id="swiftmailer.transport" alias="swiftmailer.transport.smtp" public="false" />
</services>
</container>

View File

@@ -0,0 +1,53 @@
{% extends 'WebProfilerBundle:Profiler:layout.html.twig' %}
{% block toolbar %}
{% if collector.messagecount %}
{% set icon %}
<img width="23" height="28" alt="Swiftmailer" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABcAAAAcCAYAAACK7SRjAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMC1jMDYwIDYxLjEzNDc3NywgMjAxMC8wMi8xMi0xNzozMjowMCAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RSZWY9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZVJlZiMiIHhtcDpDcmVhdG9yVG9vbD0iQWRvYmUgUGhvdG9zaG9wIENTNSBNYWNpbnRvc2giIHhtcE1NOkluc3RhbmNlSUQ9InhtcC5paWQ6N0NEOTU1MjM0OThFMTFFMDg3NzJBNTE2ODgwQzMxMzQiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6N0NEOTU1MjQ0OThFMTFFMDg3NzJBNTE2ODgwQzMxMzQiPiA8eG1wTU06RGVyaXZlZEZyb20gc3RSZWY6aW5zdGFuY2VJRD0ieG1wLmlpZDoxMEQ5OTQ5QzQ5OEMxMUUwODc3MkE1MTY4ODBDMzEzNCIgc3RSZWY6ZG9jdW1lbnRJRD0ieG1wLmRpZDo3Q0Q5NTUyMjQ5OEUxMUUwODc3MkE1MTY4ODBDMzEzNCIvPiA8L3JkZjpEZXNjcmlwdGlvbj4gPC9yZGY6UkRGPiA8L3g6eG1wbWV0YT4gPD94cGFja2V0IGVuZD0iciI/PpkRnSAAAAJ0SURBVHjaYvz//z8DrQATAw3BqOFYAaO9vT1FBhw4cGCAXA5MipxBQUHT3r17l0AVAxkZ/wkLC89as2ZNIcjlYkALXKnlWqBZTH/+/PEDmQsynLW/v3+NoaHhN2oYDjJn8uTJK4BMNpDhPwsLCwOKiop2+fn5vafEYC8vrw8gc/Lz8wOB3B8gw/nev38vn5WV5eTg4LA/Ly/vESsrK2npmYmJITU19SnQ8L0gc4DxpwgyF2S4EEjB58+f+crLy31YWFjOt7S0XBYUFPxHjMEcHBz/6+rqboqJiZ0qKSnxBpkDlRICGc4MU/j792+2CRMm+L18+fLSxIkTDykoKPzBZ7CoqOi/np6eE8rKylvb29v9fvz4wYEkzYKRzjk5OX/LyMjcnDRpEkjjdisrK6wRraOj8wvokAMLFy788ejRoxcaGhrPCWai4ODgB8DUE3/mzBknYMToASNoMzAfvEVW4+Tk9LmhoWFbTU2NwunTpx2BjiiMjo6+hm4WCzJHUlLyz+vXrxkfP36sDOI/ffpUPikpibe7u3sLsJjQW7VqlSrQxe+Avjmanp7u9PbtWzGQOmCCkARmmu/m5uYfT548yY/V5UpKSl+2b9+uiiz26dMnIWBSDTp27NgdYGrYCIzwE7m5uR4wg2Hg/PnzSsDI/QlKOcjZ3wGUBLm5uf+DwLdv38gub4AG/xcSEvr35s0bZmCB5sgCE/z69SsjyDJKMtG/f/8YQQYD8wkoGf8H51AbG5sH1CpbQBnQ09PzBiiHgoIFFHlBQGwLxLxUMP8dqJgH4k3gIhfIkAKVYkDMTmmhCHIxEL8A4peMo02L4WU4QIABANxZAoDIQDv3AAAAAElFTkSuQmCC" />
<span class="sf-toolbar-status">{{ collector.messageCount }}</span>
{% endset %}
{% set text %}
<div class="sf-toolbar-info-piece">
<b>Messages</b>
<span>{{ collector.messageCount }}</span>
</div>
<div class="sf-toolbar-info-piece">
<b>Is spooled ?</b>
<span>{{ collector.isSpool ? 'yes' : 'no' }}</span>
</div>
{% endset %}
{% include 'WebProfilerBundle:Profiler:toolbar_item.html.twig' with { 'link': profiler_url } %}
{% endif %}
{% endblock %}
{% block menu %}
<span class="label">
<span class="icon"><img src="{{ asset('bundles/webprofiler/images/profiler/mail.png') }}" alt="Configuration" /></span>
<strong>E-Mails</strong>
<span class="count">
<span>{{ collector.messagecount }}</span>
</span>
</span>
{% endblock %}
{% block panel %}
<h2>Messages {{ collector.isSpool ? 'spooled' : 'sent' }}</h2>
{% if not collector.messages %}
<p>
<em>No message sent.</em>
</p>
{% else %}
{% for i, message in collector.messages %}
<h3>Message {{ i + 1 }} / {{ collector.messagecount }}</h3>
{% for header in message.headers.all %}
<pre>{{ header }}</pre>
{% endfor %}
<p>
<pre>{{ message.body|e('html', message.charset)|convert_encoding('UTF-8', message.charset) }}</pre>
</p>
{% endfor %}
{% endif %}
{% endblock %}

View File

@@ -0,0 +1,31 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\SwiftmailerBundle;
use Symfony\Component\HttpKernel\Bundle\Bundle;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Bundle\SwiftmailerBundle\DependencyInjection\Compiler\RegisterPluginsPass;
/**
* Bundle.
*
* @author Fabien Potencier <fabien@symfony.com>
*/
class SwiftmailerBundle extends Bundle
{
public function build(ContainerBuilder $container)
{
parent::build($container);
$container->addCompilerPass(new RegisterPluginsPass());
}
}

View File

@@ -0,0 +1,57 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\SwiftmailerBundle\Tests\DependencyInjection;
use Symfony\Bundle\SwiftmailerBundle\Tests\TestCase;
use Symfony\Bundle\SwiftmailerBundle\DependencyInjection\SwiftmailerExtension;
use Symfony\Component\DependencyInjection\ContainerBuilder;
class SwiftmailerExtensionTest extends TestCase
{
public function testConfigLoad()
{
$container = new ContainerBuilder();
$container->setParameter('kernel.debug', false);
$loader = new SwiftmailerExtension();
$loader->load(array(array()), $container);
$this->assertEquals('Swift_Mailer', $container->getParameter('swiftmailer.class'), '->load() loads the swiftmailer.xml file if not already loaded');
$loader->load(array(array('transport' => 'sendmail')), $container);
$this->assertEquals('swiftmailer.transport.sendmail', (string) $container->getAlias('swiftmailer.transport'));
$loader->load(array(array()), $container);
$this->assertEquals('swiftmailer.transport.smtp', (string) $container->getAlias('swiftmailer.transport'));
}
public function testNullTransport()
{
$container = new ContainerBuilder();
$container->setParameter('kernel.debug', false);
$loader = new SwiftmailerExtension();
$loader->load(array(array('transport' => null)), $container);
$this->assertEquals('swiftmailer.transport.null', (string) $container->getAlias('swiftmailer.transport'));
}
public function testSpool()
{
$container = new ContainerBuilder();
$container->setParameter('kernel.debug', false);
$loader = new SwiftmailerExtension();
$loader->load(array(array('spool' => array())), $container);
$this->assertEquals('swiftmailer.transport.spool', (string) $container->getAlias('swiftmailer.transport'));
$this->assertEquals('swiftmailer.transport.smtp', (string) $container->getAlias('swiftmailer.transport.real'));
}
}

View File

@@ -0,0 +1,22 @@
<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Bundle\SwiftmailerBundle\Tests;
class TestCase extends \PHPUnit_Framework_TestCase
{
protected function setUp()
{
if (!class_exists('Swift_Mailer')) {
$this->markTestSkipped('Swiftmailer is not available.');
}
}
}

View File

@@ -0,0 +1,33 @@
{
"name": "symfony/swiftmailer-bundle",
"type": "symfony-bundle",
"description": "Symfony SwiftmailerBundle",
"keywords": [],
"homepage": "http://symfony.com",
"version": "2.1.0",
"license": "MIT",
"authors": [
{
"name": "Fabien Potencier",
"email": "fabien@symfony.com"
},
{
"name": "Symfony Community",
"homepage": "http://symfony.com/contributors"
}
],
"require": {
"php": ">=5.3.2",
"swiftmailer/swiftmailer": ">=4.1.8,<4.2-dev",
"symfony/swiftmailer-bridge": "self.version"
},
"autoload": {
"psr-0": { "Symfony\\Bundle\\SwiftmailerBundle": "" }
},
"target-dir": "Symfony/Bundle/SwiftmailerBundle",
"extra": {
"branch-alias": {
"dev-master": "2.1.x-dev"
}
}
}