|
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
|
|
|
|