Completed
Push — issue/AZ_53_respond_to_spam_ev... ( b7bb66 )
by Dominik
13:55
created

Configuration::addSpamAlertsSection()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 16
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 14
nc 1
nop 1
1
<?php
2
3
namespace Azine\MailgunWebhooksBundle\DependencyInjection;
4
5
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
6
use Symfony\Component\Config\Definition\ConfigurationInterface;
7
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
8
9
/**
10
 * This is the class that validates and merges configuration from your app/config files
11
 *
12
 * To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html#cookbook-bundles-extension-config-class}
13
 */
14
class Configuration implements ConfigurationInterface
15
{
16
    /**
17
     * {@inheritDoc}
18
     */
19
    public function getConfigTreeBuilder()
20
    {
21
        $treeBuilder = new TreeBuilder();
22
        $rootNode = $treeBuilder->root(AzineMailgunWebhooksExtension::PREFIX);
23
24
        $rootNode
25
            ->children()
26
                ->scalarNode(AzineMailgunWebhooksExtension::API_KEY)->isRequired()->cannotBeEmpty()->info("Your api-key for mailgun => see https://mailgun.com/cp")->end()
27
                ->scalarNode(AzineMailgunWebhooksExtension::PUBLIC_API_KEY)->defaultValue("")->info("Your public-api-key for mailgun => see https://mailgun.com/cp")->end()
28
            ->end();
29
30
        $this->addSpamAlertsSection($rootNode);
31
32
        return $treeBuilder;
33
    }
34
35
    /**
36
     * @param ArrayNodeDefinition $node
37
     */
38
    private function addSpamAlertsSection(ArrayNodeDefinition $node)
39
    {
40
        $node
41
            ->children()
42
                ->arrayNode('spam_alerts')
43
                    ->addDefaultsIfNotSet()
44
                    ->canBeUnset()
45
                    ->children()
46
                        ->booleanNode(AzineMailgunWebhooksExtension::SEND_ENABLED)->defaultFalse()->info("Whether to send email notifications after receiving spam complaints")->end()
47
                        ->scalarNode(AzineMailgunWebhooksExtension::SEND_INTERVAL)->defaultValue('60')->info("Interval in minutes between sending of email notifications after receiving spam complaints")->end()
48
                        ->scalarNode(AzineMailgunWebhooksExtension::TICKET_ID)->defaultValue("")->info("Mailgun helpdesk ticket ID to request new IP address in case of spam complains")->end()
49
                        ->scalarNode(AzineMailgunWebhooksExtension::TICKET_SUBJECT)->defaultValue("IP on spam-list, please fix.")->info("Mailgun HelpDesk ticket subject")->end()
50
                        ->scalarNode(AzineMailgunWebhooksExtension::TICKET_MESSAGE)->defaultValue("It looks like my ip is on a spam-list. Please, assign a clean IP to my domain.")->info("Mailgun HelpDesk ticket subject")->end()
51
                        ->scalarNode(AzineMailgunWebhooksExtension::ALERTS_RECIPIENT_EMAIL)->defaultValue("")->info("Admin E-Mail to send notification about spam complaints")->end()
52
        ->end();
53
    }
54
}
55