services:
  DH\Auditor\Configuration:
    class: DH\Auditor\Configuration
    arguments:
      - '%dh_auditor.configuration%'

  DH\Auditor\Auditor:
    class: DH\Auditor\Auditor
    arguments:
      - '@DH\Auditor\Configuration'
      - '@event_dispatcher'

  # DoctrineProvider services
  DH\Auditor\Provider\Doctrine\Configuration:
    class: DH\Auditor\Provider\Doctrine\Configuration
    arguments:
      - '%dh_auditor.provider.doctrine.configuration%'

  DH\Auditor\Provider\Doctrine\DoctrineProvider:
    class: DH\Auditor\Provider\Doctrine\DoctrineProvider
    arguments:
      - '@DH\Auditor\Provider\Doctrine\Configuration'
    calls:
      - [setAuditor, ['@DH\Auditor\Auditor']]
    tags:
      - { name: dh_auditor.provider }
  dh_auditor.provider.doctrine: '@DH\Auditor\Provider\Doctrine\DoctrineProvider'

  DH\AuditorBundle\Routing\RoutingLoader:
    arguments:
      - '@routing.loader.attribute'
      - '%dh_auditor.provider.doctrine.configuration%'
    tags:
      - { name: routing.loader }

  DH\Auditor\Provider\Doctrine\Persistence\Reader\Reader:
    class: DH\Auditor\Provider\Doctrine\Persistence\Reader\Reader
    arguments:
      - '@DH\Auditor\Provider\Doctrine\DoctrineProvider'

  DH\Auditor\Provider\Doctrine\Persistence\Event\CreateSchemaListener:
    class: DH\Auditor\Provider\Doctrine\Persistence\Event\CreateSchemaListener
    arguments: ['@DH\Auditor\Provider\Doctrine\DoctrineProvider']
    tags:
      - { name: doctrine.event_listener, event: postGenerateSchemaTable }

  DH\Auditor\Provider\Doctrine\Persistence\Event\TableSchemaListener:
    class: DH\Auditor\Provider\Doctrine\Persistence\Event\TableSchemaListener
    arguments: ['@DH\Auditor\Provider\Doctrine\DoctrineProvider']
    tags:
      - { name: doctrine.event_listener, event: loadClassMetadata }

  DH\Auditor\Provider\Doctrine\Persistence\Command\CleanAuditLogsCommand:
    class: DH\Auditor\Provider\Doctrine\Persistence\Command\CleanAuditLogsCommand
    tags:
      - { name: 'console.command', command: 'audit:clean' }
    calls:
      - [setAuditor, ['@DH\Auditor\Auditor']]

  DH\Auditor\Provider\Doctrine\Persistence\Command\UpdateSchemaCommand:
    class: DH\Auditor\Provider\Doctrine\Persistence\Command\UpdateSchemaCommand
    tags:
      - { name: 'console.command', command: 'audit:schema:update' }
    calls:
      - [setAuditor, ['@DH\Auditor\Auditor']]

  # Bundle related services
  DH\AuditorBundle\Controller\ViewerController:
    arguments: ['@twig']
    tags: ['controller.service_arguments']

  DH\AuditorBundle\User\UserProvider:
    class: DH\AuditorBundle\User\UserProvider
    arguments: ['@security.token_storage']
  dh_auditor.user_provider: '@DH\AuditorBundle\User\UserProvider'

  DH\AuditorBundle\User\ConsoleUserProvider:
    class: DH\AuditorBundle\User\ConsoleUserProvider

  DH\AuditorBundle\Security\SecurityProvider:
    class: DH\AuditorBundle\Security\SecurityProvider
    arguments: ['@request_stack', '@security.firewall.map']
  dh_auditor.security_provider: '@DH\AuditorBundle\Security\SecurityProvider'

  DH\AuditorBundle\Security\RoleChecker:
    class: DH\AuditorBundle\Security\RoleChecker
    arguments: ['@security.authorization_checker', '@DH\Auditor\Provider\Doctrine\DoctrineProvider']
  dh_auditor.role_checker: '@DH\AuditorBundle\Security\RoleChecker'

  DH\AuditorBundle\Event\ViewerEventSubscriber:
    class: DH\AuditorBundle\Event\ViewerEventSubscriber
    arguments: ['@DH\Auditor\Auditor']
    tags:
      - { name: kernel.event_subscriber }

  DH\AuditorBundle\Event\ConsoleEventSubscriber:
    arguments: ['@DH\AuditorBundle\User\ConsoleUserProvider', '@DH\Auditor\Configuration', '@dh_auditor.user_provider']
    tags:
      - { name: kernel.event_subscriber }
