services:
    _defaults:
        autowire: true
        autoconfigure: true
        public: false

    # ======
    # KERNEL
    # ======

    App\Application\Symfony\EventSubscriber\Kernel\:
        resource: '../../src/Application/Symfony/EventSubscriber/Kernel'

    App\Application\Symfony\EventSubscriber\Kernel\IdleSubscriber:
        arguments:
            $expirationTime: '%env(APP_COOKIE_IDLE_TIMEOUT)%'

    App\Domain\Registry\Symfony\EventSubscriber\Kernel\ConformiteTraitementSubscriber: ~
    App\Domain\Registry\Symfony\EventSubscriber\Kernel\ConformiteOrganisationSubscriber: ~
    App\Domain\Reporting\Symfony\EventSubscriber\Kernel\LogJournalSubscriber: ~
    App\Domain\User\Symfony\EventSubscriber\Kernel\SwitchUserSubscriber: ~
    App\Domain\User\Symfony\EventSubscriber\Kernel\ExceptionSubscriber: ~

    # ========
    # DOCTRINE
    # ========
    App\Application\Symfony\EventSubscriber\Doctrine\:
        resource: '../../src/Application/Symfony/EventSubscriber/Doctrine'
        exclude:
            - '../../src/Application/Symfony/EventSubscriber/Doctrine/LinkCreatorSubscriber.php'
#            - '../../src/Application/Symfony/EventSubscriber/Doctrine/LinkUpdatedBySubscriber.php'
        tags:
            - { name: 'doctrine.event_subscriber' }

    App\Application\Symfony\EventSubscriber\Doctrine\LinkCreatorSubscriber:
        arguments:
            $linkAdmin: '%env(bool:APP_IMPERSONATE_CREATOR_IS_ADMIN)%'
        tags:
            - { name: 'doctrine.event_subscriber' }

    App\Application\Symfony\EventSubscriber\Doctrine\LinkUpdatedBySubscriber:
        arguments:
            $linkAdmin: '%env(bool:APP_IMPERSONATE_CREATOR_IS_ADMIN)%'
        tags:
            - { name: 'doctrine.event_subscriber' }

    App\Domain\:
        resource: '../../src/Domain/*/Symfony/EventSubscriber/Doctrine'
        tags:
            - { name: 'doctrine.event_subscriber' }

    App\Domain\User\Symfony\EventSubscriber\Doctrine\DefinePasswordSubscriber:
        tags:
            - { name: 'doctrine.event_subscriber', priority: 2 }

    App\Application\Symfony\EventSubscriber\Kernel\LoginSubscriber:
        arguments:
            $logJournalDuration: '%env(APP_LOG_JOURNAL_DURATION)%'

    App\Domain\User\Symfony\EventSubscriber\Security\AuthenticationSubscriber:
        arguments:
            $requestStack: '@request_stack'
            $loginAttemptRepository: '@App\Domain\User\Repository\LoginAttempt'
            $userRepository: '@App\Domain\User\Repository\User'
            $maxAttempts: '%env(int:APP_MAX_LOGIN_ATTEMPTS)%'

    Symfony\Component\Cache\Adapter\ArrayAdapter: ~

    App\Domain\Reporting\Symfony\EventSubscriber\Doctrine\LogJournalDoctrineSubscriber:
        arguments:
            $cacheAdapter: '@Symfony\Component\Cache\Adapter\ArrayAdapter'
        tags:
            - { name: 'doctrine.event_subscriber' }

    App\EventSubscriber\LogoutSubscriber: ~
