parameters:
     #security.authentication.success_handler.class: D2\UserBundle\Handler\LoginSuccessHandler
    
services:
    d2.security.user_provider:
        class: D2\UserBundle\Security\UserProvider
        arguments: [@fos_user.user_manager]

    d2.registration_success:
        class: D2\UserBundle\EventListener\RegistrationSuccessListener
        arguments: [@doctrine.orm.entity_manager, @router]
        tags:
            - { name: kernel.event_subscriber }

    d2.registration_confirm:
        class: D2\UserBundle\EventListener\RegistrationConfirmListener
        arguments: [@router]
        tags:
            - { name: kernel.event_subscriber }

    d2.registration_completed:
        class: D2\UserBundle\EventListener\RegistrationCompletedListener
        arguments: [@doctrine.orm.entity_manager, @router]
        tags:
            - { name: kernel.event_subscriber }

    d2.authentication_failed:
        class: D2\UserBundle\EventListener\AuthenticationFailureListener
        arguments: [@fos_user.user_manager, @doctrine.orm.entity_manager, @router]
        tags:
            - { name: kernel.event_subscriber }
    
    app.authentication_success_handler:
        class: D2\UserBundle\Handler\LoginSuccessHandler
        arguments: [@router, @security.token_storage, @event_dispatcher, @security.context]
        scope: request
        tags:
            - { name: kernel.event_listener, event: security.interactive_login, method: onSecurityInteractiveLogin }
    
    security.user_checker:
        class: D2\UserBundle\Security\CustomUserChecker
        arguments: [@fos_user.user_manager, @doctrine.orm.entity_manager, @router]
        
#    security.authentication.customized_success_handler:
#        class: %security.authentication.success_handler.class%
#        public: false
#        arguments:  [@doctrine.orm.entity_manager, @router, @security.context]

    d2_user.registration.form.type:
        class: D2\UserBundle\Form\Type\RegistrationFormType
        arguments: [%fos_user.model.user.class%]
        tags:
            - { name: form.type, alias: d2_user_registration }

    d2_user.profile.form.type:
        class: D2\UserBundle\Form\Type\ProfileFormType
        arguments: [%fos_user.model.user.class%]
        tags:
            - { name: form.type, alias: d2_user_profile }
