parameters:
    # Redefining the default router class to implement the RequestMatcherInterface
    router.class: eZ\Bundle\EzPublishCoreBundle\Routing\DefaultRouter
    ezpublish.default_router.non_siteaccess_aware_routes: ['_assetic_', '_wdt', '_profiler', '_configurator_']
    ezpublish.default_router.legacy_aware_routes: ['_ezpublishLegacyTreeMenu', 'ezpublish_rest_', '_ezpublishPreviewContent', '_wdt', '_profiler', '_assetic']

    ezpublish.chain_router.class: eZ\Publish\Core\MVC\Symfony\Routing\ChainRouter
    ezpublish.url_generator.base.class: eZ\Publish\Core\MVC\Symfony\Routing\Generator
    ezpublish.urlalias_router.class: eZ\Bundle\EzPublishCoreBundle\Routing\UrlAliasRouter
    ezpublish.urlalias_generator.class: eZ\Publish\Core\MVC\Symfony\Routing\Generator\UrlAliasGenerator
    ezpublish.siteaccess.matcher_builder.class: eZ\Bundle\EzPublishCoreBundle\SiteAccess\MatcherBuilder
    ezpublish.siteaccess_router.class: eZ\Publish\Core\MVC\Symfony\SiteAccess\Router
    ezpublish.siteaccess_listener.class: eZ\Bundle\EzPublishCoreBundle\EventListener\SiteAccessListener
    ezpublish.siteaccess_listener.routing.class: eZ\Bundle\EzPublishCoreBundle\EventListener\RoutingListener
    ezpublish.request_redirect_listener.class: eZ\Bundle\EzPublishCoreBundle\EventListener\RequestEventListener
    ezpublish.siteaccess_match_listener.class: eZ\Publish\Core\MVC\Symfony\EventListener\SiteAccessMatchListener
    ezpublish.route_reference.generator.class: eZ\Publish\Core\MVC\Symfony\Routing\Generator\RouteReferenceGenerator
    ezpublish.route_reference.listener.language_switch.class: eZ\Publish\Core\MVC\Symfony\EventListener\LanguageSwitchListener
    ezpublish.original_request_listener.class: eZ\Bundle\EzPublishCoreBundle\EventListener\OriginalRequestListener

services:
    ezpublish.chain_router:
        class: %ezpublish.chain_router.class%
        arguments: [@?logger]
        calls:
            - [setContext, [@router.request_context]]

    ezpublish.siteaccess_match_listener:
        class: %ezpublish.siteaccess_match_listener.class%
        arguments: [@ezpublish.siteaccess_router, @event_dispatcher, @fos_http_cache.user_context.request_matcher]
        tags:
            - { name: kernel.event_subscriber }

    ezpublish.url_generator.base:
        class: %ezpublish.url_generator.base.class%
        abstract: true
        calls:
            - [setRequestContext, [@router.request_context]]
            - [setSiteAccess, [@?ezpublish.siteaccess=]]
            - [setSiteAccessRouter, [@ezpublish.siteaccess_router]]
            - [setLogger, [@?logger]]

    ezpublish.urlalias_router:
        class: %ezpublish.urlalias_router.class%
        arguments:
            - @ezpublish.api.service.location
            - @ezpublish.api.service.url_alias
            - @ezpublish.api.service.content
            - @ezpublish.urlalias_generator
            - @?router.request_context
            - @?logger
        calls:
            - [setConfigResolver, [@ezpublish.config.resolver]]
        tags:
            - {name: router, priority: 200}

    ezpublish.urlalias_generator:
        class: %ezpublish.urlalias_generator.class%
        arguments: [@ezpublish.api.repository, @router.default, @ezpublish.config.resolver]
        parent: ezpublish.url_generator.base

    ezpublish.siteaccess.matcher_builder:
        class: %ezpublish.siteaccess.matcher_builder.class%
        arguments: [@service_container]

    ezpublish.siteaccess_router:
        class: %ezpublish.siteaccess_router.class%
        arguments:
            - @ezpublish.siteaccess.matcher_builder
            - @logger
            - %ezpublish.siteaccess.default%
            - %ezpublish.siteaccess.match_config%
            - %ezpublish.siteaccess.list%
            - %ezpublish.siteaccess.class%

    ezpublish.siteaccess_listener:
        class: %ezpublish.siteaccess_listener.class%
        arguments: [@router.default, @ezpublish.urlalias_generator, @security.http_utils]
        calls:
            - [setContainer, [@service_container]]
        tags:
            - { name: kernel.event_subscriber }

    ezpublish.siteaccess_listener.routing:
        class: %ezpublish.siteaccess_listener.routing.class%
        arguments: [@ezpublish.config.resolver, @ezpublish.urlalias_router, @ezpublish.urlalias_generator]
        tags:
            - { name: kernel.event_subscriber }

    ezpublish.request_redirect_listener:
        class: %ezpublish.request_redirect_listener.class%
        arguments:
            - @ezpublish.config.resolver
            - @router
            - %ezpublish.siteaccess.default%
            - @?logger
        tags:
            - { name: kernel.event_subscriber }

    ezpublish.route_reference.generator:
      class: %ezpublish.route_reference.generator.class%
      arguments: [@event_dispatcher]
      calls:
        - [setRequest, [@?request=]]

    ezpublish.route_reference.listener.language_switch:
        class: %ezpublish.route_reference.listener.language_switch.class%
        arguments: [@ezpublish.translation_helper]
        tags:
            - { name: kernel.event_subscriber }

    ezpublish.original_request_listener:
        class: %ezpublish.original_request_listener.class%
        tags:
            - { name: kernel.event_subscriber }
