services:
    _defaults:
        autowire: true
        autoconfigure: true

    # define controllers as services
    AutoAdmin\Bundle\Content\Controller\:
        resource: '../../Controller/*'
        exclude: '../../Controller/{AbstractContentController.php,ContentControllerInterface.php}'
        tags:
            - 'content.controller'

    AutoAdmin\Bundle\Content\Logger\:
        resource: '../../Logger/*'
        exclude: '../../Logger/{LoggerInterface.php}'
        tags:
            - 'aa_content.logger'

    AutoAdmin\Bundle\Content\Twig\Extension\ContentExtension:
        public: false
        tags:
            - { name: 'twig.extension' }
        arguments:
            - '@AutoAdmin\Bundle\Content\Routing\ContentRouter'
            - '@AutoAdmin\Bundle\Content\ContentReference\ContentReferenceResolver'

    AutoAdmin\Bundle\Content\Twig\Extension\SiteContextExtension:
        tags:
            - { name: 'twig.extension' }

    AutoAdmin\Bundle\Content\Routing\ContentRouter:
        arguments:
            - '@AutoAdmin\Bundle\Content\Configuration\ConfigManager'
            - '@router'
            - '@AutoAdmin\Bundle\Content\Translation\LocaleResolver'
            - '@AutoAdmin\Bundle\Content\Routing\AutoRouterManager'
            - '@AutoAdmin\Bundle\Content\Resolver\ContentResolver'
            - '@AutoAdmin\Bundle\Content\Site\SiteContextHelper'

    AutoAdmin\Bundle\Content\Repository\StaticTextRepository:
        public: true
        tags:
            - 'aa_content.repository'

    AutoAdmin\Bundle\Content\Repository\SiteRepository:
        public: true
        arguments:
            - '@Doctrine\Persistence\ManagerRegistry'
        tags:
            - { name: 'doctrine.repository_service' }

    AutoAdmin\Bundle\Content\Repository\DomainRepository:
        public: true
        arguments:
            - '@Doctrine\Persistence\ManagerRegistry'
        tags:
            - { name: 'doctrine.repository_service' }

    AutoAdmin\Bundle\Content\Repository\LocaleRepository:
        public: true
        arguments:
            - '@Doctrine\Persistence\ManagerRegistry'
        tags:
            - { name: 'doctrine.repository_service' }

    AutoAdmin\Bundle\Content\Repository\LogRepository:
        public: true
        arguments:
            - '@Doctrine\Persistence\ManagerRegistry'
        tags:
            - { name: 'doctrine.repository_service' }

    AutoAdmin\Bundle\Content\Doctrine\EventListener\CreateUpdateSubscriber:
        tags:
            - { name: 'doctrine.event_subscriber', connection: 'default' }

    AutoAdmin\Bundle\Content\Doctrine\EventListener\SlugSubscriber:
        arguments:
            - '@AutoAdmin\Bundle\Core\Slugger\Slugger'
        tags:
            - { name: 'doctrine.event_subscriber', connection: 'default', priority: 20 }

    AutoAdmin\Bundle\Content\Validator\UniqueSlugValidator:
        arguments:
            - '@Doctrine\ORM\EntityManagerInterface'
        tags:
            - { name: 'validator.constraint_validator' }

    AutoAdmin\Bundle\Content\Doctrine\EventListener\SiteContextSubscriber:
        arguments:
            - '@AutoAdmin\Bundle\Content\Site\SiteContextHelper'
        tags:
            - { name: 'doctrine.event_subscriber', connection: 'default' }

    AutoAdmin\Bundle\Content\Context\ContentContext:
        public: true
        arguments:
            - '@request_stack'

    AutoAdmin\Bundle\Content\Site\SiteMatcher: ~
    AutoAdmin\Bundle\Content\Site\HostLocaleFinder: ~

    AutoAdmin\Bundle\Content\Configuration\ConfigManager:
        arguments:
            - '%aa_content.config%'

    # route loader
    AutoAdmin\Bundle\Content\Routing\ContentRouteLoader:
        public: true
        arguments:
            - '@AutoAdmin\Bundle\Content\Configuration\ConfigManager'
        tags:
            - { name: 'routing.route_loader' }

    AutoAdmin\Bundle\Content\EventListener\MainContentRequestSubscriber:
        arguments:
            - '@AutoAdmin\Bundle\Content\Context\ContentContext'
            - '@Symfony\Component\EventDispatcher\EventDispatcherInterface'
            - '@Setono\BotDetectionBundle\BotDetector\BotDetectorInterface'
            - '@AutoAdmin\Bundle\Seo\Renderer\RendererManager'
        tags:
            - { name: 'kernel.event_subscriber' }

    AutoAdmin\Bundle\Content\EventListener\SiteRequestListener:
        arguments:
            - '@AutoAdmin\Bundle\Content\Site\SiteContextHelper'
            - '@AutoAdmin\Bundle\Content\Site\SiteMatcher'
        tags:
            #            we want to be triggered after priority 32, higher is called first so 29 should be good
            #            #7      Symfony\Component\HttpKernel\EventListener\RouterListener::onKernelRequest() 32
            - { name: 'kernel.event_listener', event: 'kernel.request', priority: 29 }
            - { name: 'kernel.event_listener', event: 'kernel.exception', priority: -80 }

    AutoAdmin\Bundle\Content\EventListener\ContentMatcherListener:
        arguments:
            - '@AutoAdmin\Bundle\Content\Configuration\ConfigManager'
            - '@doctrine'
            - '@Psr\Log\LoggerInterface'
        tags:
            - { name: 'kernel.event_listener', event: 'content.match' }

    AutoAdmin\Bundle\Content\EventListener\LoggingListener:
        arguments:
            - "@security.token_storage"
            - '@AutoAdmin\Bundle\Content\Routing\ContentRouter'
            - '@AutoAdmin\Bundle\Admin\Router\AdminRouter'
            - '@Doctrine\Persistence\ManagerRegistry'
            - '@request_stack'
            - '@AutoAdmin\Bundle\Content\Service\LoggerService'
            - '%kernel.environment%'
        tags:
            - { name: 'doctrine.event_listener', event: 'preUpdate' }
            - { name: 'doctrine.event_listener', event: 'onFlush' }

    AutoAdmin\Bundle\Content\ContentReference\ContentReferenceResolver:
        arguments:
            - '@AutoAdmin\Bundle\Content\Configuration\ConfigManager'
            - '@Doctrine\Persistence\ManagerRegistry'
            - '@AutoAdmin\Bundle\Content\Routing\ContentRouter'
            - '@request_stack'

    AutoAdmin\Bundle\Content\Profiler\SiteContextCollector:
        arguments:
            - '@AutoAdmin\Bundle\Content\Site\SiteContextHelper'
        tags:
            -   name: 'data_collector'
                template: '@AutoAdminContent/profiler/site_context_collector.html.twig'
                # must match the value returned by the getName() method
                id: 'aa_content.site_context_collector'

    AutoAdmin\Bundle\Content\Site\SiteContextHelper: ~
    AutoAdmin\Bundle\Content\Site\SiteConfigBuilderHelper: ~

    AutoAdmin\Bundle\Content\Routing\AutoRouterManager:
        arguments:
            - !tagged_iterator aa_content.auto_router
            - '@AutoAdmin\Bundle\Content\Translation\EntityTranslator'

    AutoAdmin\Bundle\Content\Routing\DefaultContentAutoRouter:
        tags:
            - { name: 'aa_content.auto_router', priority: -100 }

    AutoAdmin\Bundle\Content\Resolver\ContentResolver:
        arguments:
            - '@Doctrine\Persistence\ManagerRegistry'
            - '@AutoAdmin\Bundle\Content\Configuration\ConfigManager'

    AutoAdmin\Bundle\Content\Command\CreateSiteCommand:
        arguments:
            - '@Doctrine\Persistence\ManagerRegistry'
        tags: [ 'console.command' ]

    AutoAdmin\Bundle\Content\Duplicator\AbstractDuplicator:
        arguments:
            - '@AutoAdmin\Bundle\Content\Service\DuplicatorService'
            - '@AutoAdmin\Bundle\BrickBuilder\Builder\BuilderService'
            - '@Doctrine\ORM\EntityManagerInterface'

    AutoAdmin\Bundle\Content\Duplicator\:
        parent: 'AutoAdmin\Bundle\Content\Duplicator\AbstractDuplicator'
        resource: '../../Duplicator/*'
        exclude: '../../Duplicator/{AbstractDuplicator,DuplicatorInterface}.php'
        tags: [ 'aa_content.duplicator' ]

    AutoAdmin\Bundle\Content\Service\DuplicatorService: ~

    AutoAdmin\Bundle\Content\Duplicator\FileAndImageDuplicator:
        arguments:
            - '@AutoAdmin\Bundle\Content\Service\DuplicatorService'
            - '@AutoAdmin\Bundle\BrickBuilder\Builder\BuilderService'
            - '@Doctrine\ORM\EntityManagerInterface'
            - '@AutoAdmin\Bundle\Media\Service\MediaManipulator'
        tags: [ 'aa_content.duplicator' ]

    AutoAdmin\Bundle\Content\Command\TranslationExportCommand:
        arguments:
            - '@Doctrine\ORM\EntityManagerInterface'
            - '@AutoAdmin\Bundle\Content\Translation\EntityTranslator'
            - '@property_accessor'
        tags: [ 'console.command' ]

    AutoAdmin\Bundle\Content\Command\ClearLogCommand:
        arguments:
            - '@Doctrine\Persistence\ManagerRegistry'
        tags: [ 'console.command' ]

    AutoAdmin\Bundle\Content\Service\LoggerService:
        arguments:
            - !tagged_iterator aa_content.logger

    AutoAdmin\Bundle\Content\Service\ContentService:
        arguments:
            - '@AutoAdmin\Bundle\BrickBuilder\Service\BrickService'

    AutoAdmin\Bundle\Content\Breadcrumbs\Generator\DefaultBreadcrumbsGenerator:
        tags:
            - { name: 'aa_content.breadcrumbs_generator', priority: -10 }

    AutoAdmin\Bundle\Content\Breadcrumbs\EventListener\BreadcrumbsDataSubscriber:
        tags:
            - { name: 'kernel.event_subscriber' }

    AutoAdmin\Bundle\Content\Breadcrumbs\EventListener\BreadcrumbsDisplaySubscriber:
        tags:
            - { name: 'kernel.event_subscriber' }

    AutoAdmin\Bundle\Content\Breadcrumbs\BreadcrumbsService: ~

    AutoAdmin\Bundle\Content\Breadcrumbs\Manager\BreadcrumbsGeneratorManagerInterface:
        class: AutoAdmin\Bundle\Content\Breadcrumbs\Manager\BreadcrumbsGeneratorManager
        arguments:
            - !tagged_iterator aa_content.breadcrumbs_generator
            - '@Doctrine\ORM\EntityManagerInterface'

    AutoAdmin\Bundle\Content\Frontend\FrontendUrlChecker:
        public: true
