services:
    _defaults:
        autoconfigure: true

    contao_manager.cache.bundle_clearer:
        class: Contao\ManagerBundle\Cache\BundleCacheClearer
        arguments:
            - '@?filesystem'

    contao_manager.command.debug_plugins:
        class: Contao\ManagerBundle\Command\DebugPluginsCommand
        arguments:
            - '@kernel'

    contao_manager.command.install_web_dir:
        class: Contao\ManagerBundle\Command\InstallWebDirCommand
        arguments:
            - '%kernel.project_dir%'

    contao_manager.command.maintenance_mode:
        class: Contao\ManagerBundle\Command\MaintenanceModeCommand
        arguments:
            - '%kernel.project_dir%/var/maintenance.html'
            - '@twig'

    contao_manager.command.setup:
        class: Contao\ManagerBundle\Command\ContaoSetupCommand
        arguments:
            - '%kernel.project_dir%'
            - '%contao.web_dir%'

    contao_manager.jwt_manager:
        public: true
        synthetic: true

    contao_manager.listener.backend_menu:
        class: Contao\ManagerBundle\EventListener\BackendMenuListener
        arguments:
            - '@security.helper'
            - '@router'
            - '@request_stack'
            - '@translator'
            - '%kernel.debug%'
            - '%contao_manager.manager_path%'
            - '@?contao_manager.jwt_manager'
        tags:
            - kernel.event_listener

    contao_manager.listener.doctrine_alter_table:
        class: Contao\ManagerBundle\EventListener\DoctrineAlterTableListener
        tags:
            - { name: doctrine.event_listener, event: onSchemaAlterTableRenameColumn }

    contao_manager.listener.initialize_application:
        class: Contao\ManagerBundle\EventListener\InitializeApplicationListener
        arguments:
            - '%kernel.project_dir%'
        tags:
            - { name: kernel.event_listener, priority: -128 }

    contao_manager.listener.install_command:
        class: Contao\ManagerBundle\EventListener\InstallCommandListener
        arguments:
            - '%kernel.project_dir%'
        tags:
            - kernel.event_listener

    contao_manager.plugin_loader:
        public: true
        synthetic: true

    contao_manager.routing.route_loader:
        class: Contao\ManagerBundle\Routing\RouteLoader
        public: true
        arguments:
            - '@routing.loader'
            - '@contao_manager.plugin_loader'
            - '@kernel'
            - '%kernel.project_dir%'

    contao_manager.security.logout_handler:
        class: Contao\ManagerBundle\Security\Logout\LogoutHandler
        arguments:
            - '@?contao_manager.jwt_manager'

    contao_manager.twig.file_extension_filter_iterator:
        class: Contao\ManagerBundle\Twig\FileExtensionFilterIterator
        decorates: twig.template_iterator
        arguments:
            - '@contao_manager.twig.file_extension_filter_iterator.inner'

    # Autowiring aliases
    Contao\ManagerBundle\HttpKernel\JwtManager: '@contao_manager.jwt_manager'

    # Backwards compatibility
    contao_manager.routing_loader:
        alias: contao_manager.routing.route_loader
        public: true
        deprecated:
            package: contao/manager-bundle
            version: 4.13
            message: Using the "%alias_id%" service ID has been deprecated and will no longer work in Contao 5.0. Please use "contao_manager.routing.route_loader" instead.
