<?php
/*
* This file is part of the Sylius package.
*
* (c) Paweł Jędrzejewski
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
declare(strict_types=1);
namespace Sylius\Bundle\MailerBundle\DependencyInjection;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
final class Configuration implements ConfigurationInterface
{
/**
* {@inheritdoc}
*/
public function getConfigTreeBuilder(): TreeBuilder
{
$treeBuilder = new TreeBuilder('sylius_mailer');
/** @var ArrayNodeDefinition $rootNode */
$rootNode = $treeBuilder->getRootNode();
$rootNode
->children()
->scalarNode('sender_adapter')->end()
->scalarNode('renderer_adapter')->end()
->end()
;
$this->addEmailsSection($rootNode);
return $treeBuilder;
}
private function addEmailsSection(ArrayNodeDefinition $node): void
{
$node
->children()
->arrayNode('sender')
->addDefaultsIfNotSet()
->children()
->scalarNode('name')->defaultValue('Example.com Store')->end()
->scalarNode('address')->defaultValue('no-reply@example.com')->end()
->end()
->end()
->arrayNode('emails')
->useAttributeAsKey('code')
->arrayPrototype()
->children()
->scalarNode('subject')
->setDeprecated('The "subject" option is deprecated since SyliusMailerBundle 1.5')
->end()
->scalarNode('template')->cannotBeEmpty()->end()
->booleanNode('enabled')->defaultTrue()->end()
->arrayNode('sender')
->children()
->scalarNode('name')->end()
->scalarNode('address')->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('templates')
->setDeprecated('The "templates" option is deprecated')
->useAttributeAsKey('name')
->scalarPrototype()->end()
->end()
->end()
;
}
}