PageRenderTime 26ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/src/Symfony/Bundle/SwiftmailerBundle/DependencyInjection/Configuration.php

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