services:

  aa_cache.configuration.manager:
    alias: AutoAdmin\Bundle\Cache\Configuration\ConfigManager

  AutoAdmin\Bundle\Cache\Configuration\ConfigManager:
    arguments:
      $config: '%aa_cache.config%'

  aa_cache.service.cache:
    alias: AutoAdmin\Bundle\Cache\Service\CacheService

  AutoAdmin\Bundle\Cache\Service\CacheService:
    class: 'AutoAdmin\Bundle\Cache\Service\CacheService'
    arguments:
      - '@aa_cache.configuration.manager'
      - '@doctrine'
      - '%kernel.project_dir%'

  aa_cache.listener.resetting:
    class: 'AutoAdmin\Bundle\Cache\EventListener\ResettingEventListener'
    arguments: [ '@aa_cache.service.cache' ]
    tags:
      - { name: 'doctrine.event_listener', event: 'prePersist' }
      - { name: 'doctrine.event_listener', event: 'preUpdate' }
      - { name: 'doctrine.event_listener', event: 'preRemove' }
      - { name: 'doctrine.event_listener', event: 'onFlush' }

  aa_cache.listener.cache_rule:
    class: 'AutoAdmin\Bundle\Cache\EventListener\CacheRuleEventListener'
    arguments: [ '@aa_cache.service.cache' ]
    tags:
      - { name: 'doctrine.event_listener', event: 'postPersist' }
      - { name: 'doctrine.event_listener', event: 'postUpdate' }
      - { name: 'doctrine.event_listener', event: 'postRemove' }

  aa_cache.listener.cachable:
    class: 'AutoAdmin\Bundle\Cache\EventListener\CachableEventListener'
    arguments: [ '@aa_cache.service.cache', '@security.helper' ]
    tags:
      # execute as fast as possible, just after redirect listener
      # symfony is using 32 for Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest()
      - { name: 'kernel.event_listener', event: 'kernel.request', priority: -100 }
      - { name: 'kernel.event_listener', event: 'kernel.response', priority: -1500 }

  AutoAdmin\Bundle\Cache\Repository\CacheRuleRepository:
    tags:
      - 'aa_content.repository'

  AutoAdmin\Bundle\Cache\Repository\CacheLogRepository:
    tags:
      - 'aa_content.repository'

  AutoAdmin\Bundle\Cache\Command\ClearCacheLogCommand:
    arguments:
      - '@AutoAdmin\Bundle\Admin\Helper\EntityHelper'
    tags: [ 'console.command' ]