Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converted SwiftmailerBundle to use a Configuration class
- Loading branch information
Showing
3 changed files
with
96 additions
and
51 deletions.
There are no files selected for viewing
72 changes: 72 additions & 0 deletions
72
src/Symfony/Bundle/SwiftmailerBundle/DependencyInjection/Configuration.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <fabien.potencier@symfony-project.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\DependencyInjection\Configuration\Builder\NodeBuilder; | ||
use Symfony\Component\DependencyInjection\Configuration\Builder\TreeBuilder; | ||
|
||
/** | ||
* 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 | ||
{ | ||
/** | ||
* Generates the configuration tree. | ||
* | ||
* @return \Symfony\Component\DependencyInjection\Configuration\NodeInterface | ||
*/ | ||
public function getConfigTree() | ||
{ | ||
$treeBuilder = new TreeBuilder(); | ||
$rootNode = $treeBuilder->root('swiftmailer:config', 'array'); | ||
|
||
$rootNode | ||
->scalarNode('transport') | ||
->defaultValue('smtp') | ||
->validate() | ||
->ifNotInArray(array ('smtp', 'mail', 'sendmail', 'gmail')) | ||
->thenInvalid('The %s transport is not supported') | ||
->end() | ||
->end() | ||
->scalarNode('username')->defaultNull()->end() | ||
->scalarNode('password')->defaultNull()->end() | ||
->scalarNode('host')->defaultValue('localhost')->end() | ||
->scalarNode('port')->defaultValue(25)->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') | ||
->scalarNode('type')->defaultValue('file')->end() | ||
->scalarNode('path')->defaultValue('%kernel.cache_dir%/swiftmailer/pool')->end() | ||
->end() | ||
->scalarNode('delivery_adress')->end() | ||
->booleanNode('disable_delivery')->end(); | ||
|
||
return $treeBuilder->buildTree(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters