<?php
namespace MembersBundle\DependencyInjection;
use MembersBundle\Form\Type\ChangePasswordFormType;
use MembersBundle\Form\Type\Sso\CompleteProfileFormType;
use MembersBundle\Form\Type\DeleteAccountFormType;
use MembersBundle\Form\Type\ProfileFormType;
use MembersBundle\Form\Type\RegistrationFormType;
use MembersBundle\Form\Type\LoginFormType;
use MembersBundle\Form\Type\ResettingFormType;
use MembersBundle\Form\Type\ResettingRequestFormType;
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
use Symfony\Component\Config\Definition\ConfigurationInterface;
class Configuration implements ConfigurationInterface
{
public function getConfigTreeBuilder()
{
$validPostRegisterTypes = ['confirm_by_mail', 'confirm_by_admin', 'confirm_instant'];
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('members');
$rootNode
->children()
->booleanNode('send_admin_mail_after_register')->defaultFalse()->end()
->booleanNode('send_user_mail_after_confirmed')->defaultFalse()->end()
->enumNode('post_register_type')
->values($validPostRegisterTypes)
->defaultValue('confirm_by_mail')
->end()
->enumNode('post_register_type_oauth')
->values($validPostRegisterTypes)
->defaultValue('confirm_instant')
->end()
->scalarNode('storage_path')->cannotBeEmpty()->defaultValue('/members')->end()
->arrayNode('oauth')
->addDefaultsIfNotSet()
->children()
->booleanNode('enabled')->defaultFalse()->end()
->enumNode('activation_type')
->values(['complete_profile', 'instant'])
->defaultValue('complete_profile')
->end()
->booleanNode('clean_up_expired_tokens')->defaultFalse()->end()
->integerNode('expired_tokens_ttl')->defaultValue(0)->min(0)->end()
->arrayNode('scopes')
->useAttributeAsKey('client')
->prototype('array')
->prototype('scalar')->end()
->end()
->end()
->end()
->end()
->arrayNode('user')
->addDefaultsIfNotSet()
->children()
->arrayNode('adapter')
->addDefaultsIfNotSet()
->children()
->scalarNode('class_name')->defaultValue('MembersUser')->end()
->end()
->end()
->arrayNode('initial_groups')
->prototype('scalar')->defaultValue([])->end()
->validate()
->ifEmpty()
->thenEmptyArray()
->end()
->end()
->end()
->end()
->arrayNode('group')
->addDefaultsIfNotSet()
->children()
->arrayNode('adapter')
->addDefaultsIfNotSet()
->children()
->scalarNode('class_name')->defaultValue('MembersGroup')->end()
->end()
->end()
->end()
->end()
->arrayNode('sso')
->addDefaultsIfNotSet()
->children()
->arrayNode('adapter')
->addDefaultsIfNotSet()
->children()
->scalarNode('class_name')->defaultValue('SsoIdentity')->end()
->end()
->end()
->end()
->end()
->arrayNode('auth')
->addDefaultsIfNotSet()
->children()
->arrayNode('adapter')
->addDefaultsIfNotSet()
->children()
->scalarNode('class_name')->defaultNull()->end()
->scalarNode('object_path')->defaultNull()->end()
->end()
->end()
->end()
->end()
->arrayNode('restriction')
->addDefaultsIfNotSet()
->children()
->booleanNode('enabled')->defaultFalse()->end()
->arrayNode('allowed_objects')
->prototype('scalar')->end()
->validate()
->ifEmpty()
->thenEmptyArray()
->end()
->end()
->end()
->end()
->arrayNode('relations')
->addDefaultsIfNotSet()
->children()
->arrayNode('login')
->addDefaultsIfNotSet()
->canBeUnset()
->children()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')->defaultValue(LoginFormType::class)->end()
->scalarNode('name')->defaultValue('members_user_login_form')->end()
->arrayNode('validation_groups')
->prototype('scalar')->end()
->defaultValue(['Login', 'Default'])
->end()
->end()
->end()
->end()
->end()
->arrayNode('profile')
->addDefaultsIfNotSet()
->canBeUnset()
->children()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')->defaultValue(ProfileFormType::class)->end()
->scalarNode('name')->defaultValue('members_user_profile_form')->end()
->arrayNode('validation_groups')
->prototype('scalar')->end()
->defaultValue(['Profile', 'Default'])
->end()
->end()
->end()
->end()
->end()
->arrayNode('change_password')
->addDefaultsIfNotSet()
->canBeUnset()
->children()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')->defaultValue(ChangePasswordFormType::class)->end()
->scalarNode('name')->defaultValue('members_user_change_password_form')->end()
->arrayNode('validation_groups')
->prototype('scalar')->end()
->defaultValue(['ChangePassword', 'Default'])
->end()
->end()
->end()
->end()
->end()
->arrayNode('registration')
->addDefaultsIfNotSet()
->canBeUnset()
->children()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')->defaultValue(RegistrationFormType::class)->end()
->scalarNode('name')->defaultValue('members_user_registration_form')->end()
->arrayNode('validation_groups')
->prototype('scalar')->end()
->defaultValue(['Registration', 'Default'])
->end()
->end()
->end()
->end()
->end()
->arrayNode('resetting_request')
->addDefaultsIfNotSet()
->canBeUnset()
->children()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')->defaultValue(ResettingRequestFormType::class)->end()
->scalarNode('name')->defaultValue('members_user_resetting_request_form')->end()
->arrayNode('validation_groups')
->prototype('scalar')->end()
->defaultValue(['ResetPassword', 'Default'])
->end()
->end()
->end()
->end()
->end()
->arrayNode('resetting')
->addDefaultsIfNotSet()
->canBeUnset()
->children()
->scalarNode('retry_ttl')->defaultValue(7200)->end()
->scalarNode('token_ttl')->defaultValue(86400)->end()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')->defaultValue(ResettingFormType::class)->end()
->scalarNode('name')->defaultValue('members_user_resetting_form')->end()
->arrayNode('validation_groups')
->prototype('scalar')->end()
->defaultValue(['ResetPassword', 'Default'])
->end()
->end()
->end()
->end()
->end()
->arrayNode('delete_account')
->addDefaultsIfNotSet()
->canBeUnset()
->children()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')->defaultValue(DeleteAccountFormType::class)->end()
->scalarNode('name')->defaultValue('members_user_delete_account_form')->end()
->arrayNode('validation_groups')
->prototype('scalar')->end()
->defaultValue(['DeleteAccount', 'Default'])
->end()
->end()
->end()
->end()
->end()
->arrayNode('sso_identity_complete_profile')
->addDefaultsIfNotSet()
->canBeUnset()
->children()
->arrayNode('form')
->addDefaultsIfNotSet()
->children()
->scalarNode('type')->defaultValue(CompleteProfileFormType::class)->end()
->scalarNode('name')->defaultValue('members_user_sso_identity_complete_profile_form')->end()
->arrayNode('validation_groups')
->prototype('scalar')->end()
->defaultValue(['CompleteProfile', 'Default'])
->end()
->end()
->end()
->end()
->end()
->end()
->end()
->arrayNode('emails')
->addDefaultsIfNotSet()
->children()
->arrayNode('default')
->addDefaultsIfNotSet()
->children()
->scalarNode('register_confirm')->isRequired()->defaultValue('/email/register-confirm')->end()
->scalarNode('register_confirmed')->isRequired()->defaultValue('/email/register-confirmed')->cannotBeEmpty()->end()
->scalarNode('register_password_resetting')->isRequired()->defaultValue('/email/password-reset')->cannotBeEmpty()->end()
->scalarNode('admin_register_notification')->isRequired()->defaultValue('/email/admin-register-notification')->cannotBeEmpty()->end()
->end()
->end()
->arrayNode('sites')
->prototype('array')
->children()
->scalarNode('main_domain')
->isRequired()
->cannotBeEmpty()
->end()
->arrayNode('emails')
->children()
->scalarNode('register_confirm')->isRequired()->cannotBeEmpty()->end()
->scalarNode('register_confirmed')->isRequired()->cannotBeEmpty()->end()
->scalarNode('register_password_resetting')->isRequired()->cannotBeEmpty()->end()
->scalarNode('admin_register_notification')->isRequired()->cannotBeEmpty()->end()
->end()
->end()
->end()
->end()
->end()
->end()
->end();
return $treeBuilder;
}
}