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
|
3 |
|
public function getConfigTreeBuilder() |
20
|
|
|
{ |
21
|
3 |
|
$treeBuilder = new TreeBuilder(); |
22
|
3 |
|
$rootNode = $treeBuilder->root(AzineMailgunWebhooksExtension::PREFIX); |
23
|
|
|
|
24
|
|
|
$rootNode |
25
|
3 |
|
->children() |
26
|
3 |
|
->scalarNode(AzineMailgunWebhooksExtension::API_KEY)->isRequired()->cannotBeEmpty()->info('Your api-key for mailgun => see https://mailgun.com/cp')->end() |
27
|
3 |
|
->scalarNode(AzineMailgunWebhooksExtension::PUBLIC_API_KEY)->defaultValue('')->info('Your public-api-key for mailgun => see https://mailgun.com/cp')->end() |
28
|
3 |
|
->scalarNode(AzineMailgunWebhooksExtension::EMAIL_DOMAIN)->defaultValue('')->info('Your email domain configured on Mailgun')->end() |
29
|
3 |
|
->end(); |
30
|
|
|
|
31
|
3 |
|
$this->addSpamAlertsSection($rootNode); |
32
|
|
|
$this->addBlacklistCheckSection($rootNode); |
33
|
|
|
|
34
|
|
|
return $treeBuilder; |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param ArrayNodeDefinition $node |
39
|
|
|
*/ |
40
|
3 |
|
private function addSpamAlertsSection(ArrayNodeDefinition $node) |
41
|
|
|
{ |
42
|
|
|
$node |
43
|
3 |
|
->children() |
44
|
3 |
|
->arrayNode(AzineMailgunWebhooksExtension::SPAM_ALERTS_PREFIX) |
45
|
|
|
->addDefaultsIfNotSet() |
46
|
|
|
->canBeUnset() |
47
|
|
|
->children() |
48
|
|
|
->booleanNode(AzineMailgunWebhooksExtension::SEND_ENABLED)->defaultFalse()->info("Whether to send email notifications after receiving spam complaints")->end() |
49
|
|
|
->scalarNode(AzineMailgunWebhooksExtension::SEND_INTERVAL)->defaultValue('60')->info("Interval in minutes between sending of email notifications after receiving spam complaints")->end() |
50
|
|
|
->scalarNode(AzineMailgunWebhooksExtension::TICKET_ID)->defaultValue("")->info("Mailgun helpdesk ticket ID to request new IP address in case of spam complains")->end() |
51
|
|
|
->scalarNode(AzineMailgunWebhooksExtension::TICKET_SUBJECT)->defaultValue("IP on spam-list, please fix.")->info("Mailgun HelpDesk ticket subject")->end() |
52
|
|
|
->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() |
53
|
|
|
->scalarNode(AzineMailgunWebhooksExtension::ALERTS_RECIPIENT_EMAIL)->defaultValue("")->info("Admin E-Mail to send notification about spam complaints")->end() |
54
|
|
|
->end(); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param ArrayNodeDefinition $node |
59
|
|
|
*/ |
60
|
|
|
private function addBlacklistCheckSection(ArrayNodeDefinition $node) |
61
|
|
|
{ |
62
|
|
|
$node |
63
|
|
|
->children() |
64
|
|
|
->arrayNode(AzineMailgunWebhooksExtension::HETRIXTOOLS_PREFIX) |
65
|
|
|
->addDefaultsIfNotSet() |
66
|
|
|
->canBeUnset() |
67
|
|
|
->children() |
68
|
|
|
->scalarNode(AzineMailgunWebhooksExtension::BLACKLIST_CHECK_API_KEY)->defaultValue("")->info("Your public-api-key for hetrixtools => see https://hetrixtools.com/")->end() |
69
|
|
|
->scalarNode(AzineMailgunWebhooksExtension::BLACKLIST_CHECK_IP_URL)->defaultValue("https://api.hetrixtools.com/v2/<API_TOKEN>/blacklist-check/ipv4/<IP_ADDRESS>/")->info("Url for checking if ip is in blacklist => see https://docs.hetrixtools.com/blacklist-check-api/")->end() |
70
|
|
|
->end(); |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|