|
0
|
1 |
<?php |
|
|
2 |
|
|
|
3 |
/* |
|
|
4 |
* This file is part of the Symfony package. |
|
|
5 |
* |
|
|
6 |
* (c) Fabien Potencier <fabien@symfony.com> |
|
|
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\Bundle\SwiftmailerBundle\DependencyInjection; |
|
|
13 |
|
|
|
14 |
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
|
|
15 |
use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
|
|
16 |
use Symfony\Component\Config\Definition\ConfigurationInterface; |
|
|
17 |
|
|
|
18 |
/** |
|
|
19 |
* This class contains the configuration information for the bundle |
|
|
20 |
* |
|
|
21 |
* This information is solely responsible for how the different configuration |
|
|
22 |
* sections are normalized, and merged. |
|
|
23 |
* |
|
|
24 |
* @author Christophe Coevoet <stof@notk.org> |
|
|
25 |
*/ |
|
|
26 |
class Configuration implements ConfigurationInterface |
|
|
27 |
{ |
|
|
28 |
private $debug; |
|
|
29 |
|
|
|
30 |
/** |
|
|
31 |
* Constructor. |
|
|
32 |
* |
|
|
33 |
* @param Boolean $debug The kernel.debug value |
|
|
34 |
*/ |
|
|
35 |
public function __construct($debug) |
|
|
36 |
{ |
|
|
37 |
$this->debug = (Boolean) $debug; |
|
|
38 |
} |
|
|
39 |
|
|
|
40 |
/** |
|
|
41 |
* Generates the configuration tree builder. |
|
|
42 |
* |
|
|
43 |
* @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder |
|
|
44 |
*/ |
|
|
45 |
public function getConfigTreeBuilder() |
|
|
46 |
{ |
|
|
47 |
$treeBuilder = new TreeBuilder(); |
|
|
48 |
$rootNode = $treeBuilder->root('swiftmailer'); |
|
|
49 |
|
|
|
50 |
$rootNode |
|
|
51 |
->children() |
|
|
52 |
->scalarNode('transport')->defaultValue('smtp')->end() |
|
|
53 |
->scalarNode('username')->defaultNull()->end() |
|
|
54 |
->scalarNode('password')->defaultNull()->end() |
|
|
55 |
->scalarNode('host')->defaultValue('localhost')->end() |
|
|
56 |
->scalarNode('port')->defaultFalse()->end() |
|
|
57 |
->scalarNode('encryption') |
|
|
58 |
->defaultNull() |
|
|
59 |
->validate() |
|
|
60 |
->ifNotInArray(array('tls', 'ssl', null)) |
|
|
61 |
->thenInvalid('The %s encryption is not supported') |
|
|
62 |
->end() |
|
|
63 |
->end() |
|
|
64 |
->scalarNode('auth_mode') |
|
|
65 |
->defaultNull() |
|
|
66 |
->validate() |
|
|
67 |
->ifNotInArray(array('plain', 'login', 'cram-md5', null)) |
|
|
68 |
->thenInvalid('The %s authentication mode is not supported') |
|
|
69 |
->end() |
|
|
70 |
->end() |
|
|
71 |
->arrayNode('spool') |
|
|
72 |
->children() |
|
|
73 |
->scalarNode('type')->defaultValue('file')->end() |
|
|
74 |
->scalarNode('path')->defaultValue('%kernel.cache_dir%/swiftmailer/spool')->end() |
|
|
75 |
->end() |
|
|
76 |
->end() |
|
|
77 |
->scalarNode('sender_address')->end() |
|
|
78 |
->arrayNode('antiflood') |
|
|
79 |
->children() |
|
|
80 |
->scalarNode('threshold')->defaultValue(99)->end() |
|
|
81 |
->scalarNode('sleep')->defaultValue(0)->end() |
|
|
82 |
->end() |
|
|
83 |
->end() |
|
|
84 |
->scalarNode('delivery_address')->end() |
|
|
85 |
->booleanNode('disable_delivery')->end() |
|
|
86 |
->booleanNode('logging')->defaultValue($this->debug)->end() |
|
|
87 |
->end() |
|
|
88 |
; |
|
|
89 |
|
|
|
90 |
return $treeBuilder; |
|
|
91 |
} |
|
|
92 |
} |