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

  MUTHSEV\Members\:
    resource: '../Classes/*'
    exclude: '../Classes/Domain/Model/*'

  # In2code\Femanager\Controller\NewController: '@MUTHSEV\Members\XClass\FeManager\Controller\NewController'
  # In2code\Femanager\Controller\EditController: '@MUTHSEV\Members\XClass\FeManager\Controller\EditController'

  MUTHSEV\Members\Service\AddressService:
    public: true

  MUTHSEV\Members\Domain\Repository\ContactRepository:
    public: true

  MUTHSEV\Members\EventListener\UserAccount\AugmentNavMenuItems:
    tags:
      - name: event.listener
        identifier: 'muthsevmembers--user-account--augment-user-account-nav-menu'
        event: MUTHSEV\Members\Event\ModifyUserAccountNavMenuItemsEvent
        # after: 'muthsevmembers--user-account--augment-user-account-nav-menu'

  feloginPasswordRecovery.rateLimiterFactory:
    class: Symfony\Component\RateLimiter\RateLimiterFactory
    arguments:
      $config:
        id: 'felogin-password-recovery'
        policy: 'sliding_window'
        limit: 5
        interval: '15 minutes'
      $storage: '@TYPO3\CMS\Core\RateLimiter\Storage\CachingFrameworkStorage'

#  TYPO3\CMS\FrontendLogin\Controller\PasswordRecoveryController:
#    alias: MUTHSEV\Members\XClass\FrontendLogin\Controller\PasswordRecoveryController
#    public: true
#    arguments:
#      $rateLimiterFactory: '@feloginPasswordRecovery.rateLimiterFactory'

  MUTHSEV\Members\XClass\FrontendLogin\Controller\PasswordRecoveryController:
#    alias: MUTHSEV\Members\XClass\FrontendLogin\Controller\PasswordRecoveryController
#    public: true
    arguments:
      $rateLimiterFactory: '@feloginPasswordRecovery.rateLimiterFactory'

  MUTHSEV\Members\EventListener\LoginConfirmedListener:
    tags:
      - name: event.listener
        identifier: 'vendor-extension-login-confirmed-listener'
        event: TYPO3\CMS\FrontendLogin\Event\LoginConfirmedEvent

  MUTHSEV\Members\EventListener\AfterPasswordUpdatedEventListener:
    tags:
      - name: event.listener
        identifier: 'vendor-extension-modify-update-password-response'
        method: 'modifyUpdatePasswordResponseListener'
        event: Derhansen\FeChangePwd\Event\ModifyUpdatePasswordResponseEvent
      # this event is fired after password has been updated in my account
      - name: event.listener
        identifier: 'after-password-updated-notification'
        method: 'sendPasswordChangedNotification'
        event: Derhansen\FeChangePwd\Event\AfterPasswordUpdatedEvent
        after: 'vendor-extension-modify-update-password-response'
      # this event is fire after resetting the password
      - name: event.listener
        identifier: 'muthsevmemebers--forward-to-account-page-after-password-recovery'
        method: 'reloadAccountPage'
        event: TYPO3\CMS\FrontendLogin\Event\PasswordChangeEvent

  MUTHSEV\Members\EventListener\FinalCreateEventListener:
    arguments:
      $contactRepository: '@MUTHSEV\Members\Domain\Repository\ContactRepository'
      $phoneRepository: '@MUTHSEV\Members\Domain\Repository\PhoneRepository'
    tags:
      - name: event.listener
        identifier: 'muthsevmembers--add-contact-to-user'
        method: 'createPersonAndFeUserRelation'
        event: In2code\Femanager\Event\FinalCreateEvent
      - name: event.listener
        identifier: 'muthsevmembers--reload-account-page'
        method: 'reloadAccountPage'
        event: In2code\Femanager\Event\FinalCreateEvent
        after: 'muthsevmembers--add-contact-to-user'

# todo:
#  MUTHSEV\Members\EventListener\UserUpdateEventListener:
#    arguments:
#      $contactRepository: '@MUTHSEV\Members\Domain\Repository\ContactRepository'
#    tags:
#      - name: event.listener
#        identifier: 'user-update-event-listener'
#        method: 'updateContactAfterFeUserUpdate'
#        event: In2code\Femanager\Event\FinalUpdateEvent

