parameters:
    # Below default parameters, to be defined in ezpublish/config/config.yml
    #ezpublish_legacy.enabled: false
    #ezpublish_legacy.root_dir: ~

    ezpublish_legacy.kernel.lazy_loader.class: eZ\Publish\Core\MVC\Legacy\Kernel\Loader
    ezpublish_legacy.kernel_handler.class: ezpKernelHandler
    ezpublish_legacy.kernel_handler.web.class: ezpKernelWeb
    ezpublish_legacy.kernel_handler.treemenu.class: ezpKernelTreeMenu

    ezpublish_legacy.controller.class: eZ\Bundle\EzPublishLegacyBundle\Controller\LegacyKernelController
    ezpublish_legacy.response_manager.class: eZ\Bundle\EzPublishLegacyBundle\LegacyResponse\LegacyResponseManager
    ezpublish_legacy.treemenu.controller.class: eZ\Bundle\EzPublishLegacyBundle\Controller\LegacyTreeMenuController
    ezpublish_legacy.treemenu.controller.options: {}
    ezpublish_legacy.setup.controller.class: eZ\Bundle\EzPublishLegacyBundle\Controller\LegacySetupController
    ezpublish_legacy.preview.controller.class: eZ\Bundle\EzPublishLegacyBundle\Controller\PreviewController
    ezpublish_legacy.website_toolbar.controller.class: eZ\Bundle\EzPublishLegacyBundle\Controller\WebsiteToolbarController

    ezpublish_legacy.kernel_handler.cli.class: eZ\Publish\Core\MVC\Legacy\Kernel\CLIHandler
    ezpublish_legacy.kernel_handler.cli.options: {}

    # See ezpublish_legacy.webconfigurator
    ezpublish_legacy.webconfigurator.factory.class: eZ\Bundle\EzPublishLegacyBundle\SetupWizard\ConfiguratorFactory
    ezpublish_legacy.webconfigurator.class: Sensio\Bundle\DistributionBundle\Configurator\Configurator

    ezpublish_legacy.router.class: eZ\Bundle\EzPublishLegacyBundle\Routing\FallbackRouter
    ezpublish_legacy.uri_helper.class: eZ\Publish\Core\MVC\Legacy\Kernel\URIHelper
    ezpublish_legacy.url_generator.class: eZ\Bundle\EzPublishLegacyBundle\Routing\UrlGenerator
    ezpublish_legacy.siteaccess_mapper.class: eZ\Bundle\EzPublishLegacyBundle\LegacyMapper\SiteAccess
    ezpublish_legacy.siteaccess_mapper.options: { fragment_path: %fragment.path% }
    ezpublish_legacy.session_mapper.class: eZ\Bundle\EzPublishLegacyBundle\LegacyMapper\Session
    ezpublish_legacy.configuration_mapper.class: eZ\Bundle\EzPublishLegacyBundle\LegacyMapper\Configuration
    ezpublish_legacy.configuration_mapper.options:
        imagemagick_enabled: %ezpublish.image.imagemagick.enabled%
        imagemagick_executable_path: %ezpublish.image.imagemagick.executable_path%
        imagemagick_executable: %ezpublish.image.imagemagick.executable%
        imagemagick_filters: %ezpublish.image.imagemagick.filters%
    ezpublish_legacy.legacy_bundles_mapper.class: eZ\Bundle\EzPublishLegacyBundle\LegacyMapper\LegacyBundles

    ezpublish_legacy.content_exception_handler.class: eZ\Publish\Core\MVC\Legacy\EventListener\APIContentExceptionListener
    ezpublish_legacy.config.resolver.class: eZ\Bundle\EzPublishLegacyBundle\DependencyInjection\Configuration\LegacyConfigResolver
    ezpublish_legacy.config.default_scope: site
    ezpublish_legacy.setup_wizard.configuration_converter.class: eZ\Bundle\EzPublishLegacyBundle\SetupWizard\ConfigurationConverter
    ezpublish_legacy.setup_wizard.configuration_dumper.class: eZ\Bundle\EzPublishLegacyBundle\SetupWizard\ConfigurationDumper
    # Environments to pre-generate config file for
    ezpublish_legacy.setup_wizard.configuration_dumper.environments: [dev, prod]
    # Non-supported packages will have url_alias_router to false
    ezpublish_legacy.setup_wizard.supported_packages: [ezdemo_site, ezdemo_site_clean]
    ezpublish_legacy.fieldType.ezimage.variation_service.class: eZ\Publish\Core\MVC\Legacy\Image\AliasGenerator

    # Cache purging
    ezpublish_legacy.persistence_cache_purger.class: eZ\Bundle\EzPublishLegacyBundle\Cache\PersistenceCachePurger
    ezpublish_legacy.legacy_cache_purger.class: eZ\Bundle\EzPublishLegacyBundle\Cache\LegacyCachePurger

    # Overriding base PageService for ezpage fieldtype.
    ezpublish.fieldType.ezpage.pageService.class: eZ\Bundle\EzPublishLegacyBundle\FieldType\Page\PageService

    ezpublish_legacy.rest_listener.class: eZ\Bundle\EzPublishLegacyBundle\EventListener\RestListener
    ezpublish_legacy.request_listener.class: eZ\Bundle\EzPublishLegacyBundle\EventListener\RequestListener
    ezpublish_legacy.response_listener.class: eZ\Bundle\EzPublishLegacyBundle\EventListener\CsrfTokenResponseListener
    ezpublish_legacy.config_scope_listener.class: eZ\Bundle\EzPublishLegacyBundle\EventListener\ConfigScopeListener
    ezpublish_legacy.legacy_kernel_listener.class: eZ\Bundle\EzPublishLegacyBundle\EventListener\LegacyKernelListener

    ezpublish_legacy.legacy_bundles.extension_locator.class: eZ\Bundle\EzPublishLegacyBundle\LegacyBundles\LegacyExtensionsLocator

services:
    ezpublish_legacy.kernel:
        alias: ezpublish_legacy.kernel.lazy

    ezpublish_legacy.kernel.lazy:
        class: Closure
        factory_service: ezpublish_legacy.kernel.lazy_loader
        factory_method: buildLegacyKernel
        arguments: [@ezpublish_legacy.kernel_handler]

    ezpublish_legacy.kernel.lazy_loader:
        class: %ezpublish_legacy.kernel.lazy_loader.class%
        arguments:
            - %ezpublish_legacy.root_dir%
            - %webroot_dir%
            - @event_dispatcher
            - @ezpublish_legacy.uri_helper
            - @?logger
        calls:
            - [setContainer, [@service_container]]

    ezpublish_legacy.kernel_handler.web:
        class: %ezpublish_legacy.kernel_handler.class%
        factory_service: ezpublish_legacy.kernel.lazy_loader
        factory_method: buildLegacyKernelHandlerWeb
        arguments: [%ezpublish_legacy.kernel_handler.web.class%]

    ezpublish_legacy.kernel_handler.treemenu:
        class: %ezpublish_legacy.kernel_handler.treemenu.class%
        factory_service: ezpublish_legacy.kernel.lazy_loader
        factory_method: buildLegacyKernelHandlerTreeMenu

    ezpublish_legacy.kernel_handler.cli:
        class: %ezpublish_legacy.kernel_handler.cli.class%
        factory_service: ezpublish_legacy.kernel.lazy_loader
        factory_method: buildLegacyKernelHandlerCLI

    ezpublish_legacy.kernel_handler:
        alias: ezpublish_legacy.kernel_handler.web

    ezpublish_legacy.response_manager:
        class: %ezpublish_legacy.response_manager.class%
        arguments: [@templating, @ezpublish.config.resolver]

    ezpublish_legacy.controller:
        class: %ezpublish_legacy.controller.class%
        arguments:
            - @ezpublish_legacy.kernel
            - @ezpublish.config.resolver
            - @ezpublish_legacy.uri_helper
            - @ezpublish_legacy.response_manager
            - @ezpublish_legacy.templating.legacy_helper
            - @router
        calls:
            - [setRequest, [@?request=]]

    ezpublish_legacy.treemenu.controller:
        class: %ezpublish_legacy.treemenu.controller.class%
        arguments:
            - @ezpublish_legacy.kernel_handler.treemenu
            - @ezpublish_legacy.kernel.lazy_loader
            - %ezpublish_legacy.treemenu.controller.options%
        parent: ezpublish.controller.base
        scope: request

    ezpublish_legacy.setup.controller:
        class: %ezpublish_legacy.setup.controller.class%
        parent: ezpublish.controller.base
        arguments:
            - @ezpublish_legacy.kernel
            - @ezpublish_legacy.config.resolver
            - @ezpublish_legacy.persistence_cache_purger
            - @ezpublish_legacy.kernel.lazy_loader

    ezpublish_legacy.preview.controller:
        class: %ezpublish_legacy.preview.controller.class%
        parent: ezpublish.controller.content.preview.core
        calls:
            - [setConfigResolver, [@ezpublish.config.resolver]]

    ezpublish.controller.content.preview:
        alias: ezpublish_legacy.preview.controller

    ezpublish_legacy.website_toolbar.controller:
        class: %ezpublish_legacy.website_toolbar.controller.class%
        parent: ezpublish.controller.base
        arguments:
            - @templating.engine.eztpl
            - @ezpublish.api.service.content
            - @ezpublish.api.service.location
            - @security.context
            - @?form.csrf_provider

    ezpublish_legacy.router:
        class: %ezpublish_legacy.router.class%
        arguments: [@ezpublish_legacy.url_generator, @?request_context, @?logger]
        tags:
            - {name: router, priority: -255}
        lazy: true

    ezpublish_legacy.uri_helper:
        class: %ezpublish_legacy.uri_helper.class%

    ezpublish_legacy.url_generator:
        class: %ezpublish_legacy.url_generator.class%
        arguments: [@ezpublish_legacy.kernel]
        parent: ezpublish.url_generator.base

    ezpublish_legacy.siteaccess_mapper:
        class: %ezpublish_legacy.siteaccess_mapper.class%
        arguments:
            - %ezpublish_legacy.siteaccess_mapper.options%
        calls:
            - [setContainer, [@service_container]]
        tags:
            - { name: kernel.event_subscriber }

    ezpublish_legacy.session_mapper:
        class: %ezpublish_legacy.session_mapper.class%
        arguments: [@session.storage, %ezpublish.session.attribute_bag.storage_key%, @?session]
        calls:
            - [setRequest, [@?request=]]
        tags:
            - { name: kernel.event_subscriber }

    ezpublish_legacy.configuration_mapper:
        class: %ezpublish_legacy.configuration_mapper.class%
        arguments:
            - @ezpublish.config.resolver.core
            - @ezpublish.http_cache.purger
            - @ezpublish_legacy.persistence_cache_purger
            - @ezpublish.urlalias_generator
            - @ezpublish.api.storage_engine.legacy.dbhandler
            - @ezpublish_legacy.image_alias.cleaner
            - %ezpublish_legacy.configuration_mapper.options%
        calls:
            - [setContainer, [@service_container]]
        tags:
            - { name: kernel.event_subscriber }

    ezpublish_legacy.legacy_bundles_mapper:
        class: %ezpublish_legacy.legacy_bundles_mapper.class%
        arguments:
            - @ezpublish.config.resolver.core
            - { extensions: %ezpublish_legacy.legacy_bundles_extensions% }
        tags:
            - { name: kernel.event_subscriber }

    ezpublish_legacy.persistence_cache_purger:
        class: %ezpublish_legacy.persistence_cache_purger.class%
        arguments: [@ezpublish.cache_pool.spi.cache.decorator, @ezpublish.spi.persistence.cache.locationHandler, @logger]
        tags:
            - { name: kernel.cache_clearer }
        lazy: true

    ezpublish_legacy.legacy_cache_purger:
        class: %ezpublish_legacy.legacy_cache_purger.class%
        arguments:
            - @ezpublish_legacy.kernel
            - @ezpublish_legacy.configuration_mapper
            - @filesystem
            - %ezpublish_legacy.root_dir%
            - @ezpublish.siteaccess
        tags:
            - { name: kernel.cache_clearer }

    ezpublish_legacy.content_exception_handler:
        class: %ezpublish_legacy.content_exception_handler.class%
        arguments: [@ezpublish_legacy.content_view_provider, @ezpublish_legacy.location_view_provider, @?logger]
        tags:
            - { name: kernel.event_subscriber }

    ezpublish_legacy.config.resolver:
        class: %ezpublish_legacy.config.resolver.class%
        arguments: [@ezpublish_legacy.kernel, %ezpublish_legacy.config.default_scope%]
        lazy: true
        tags:
            - { name: ezpublish.config.resolver, priority: -255 }

    ezpublish_legacy.setup_wizard.configuration_converter:
        class: %ezpublish_legacy.setup_wizard.configuration_converter.class%
        arguments: [@ezpublish_legacy.config.resolver, @ezpublish_legacy.kernel, %ezpublish_legacy.setup_wizard.supported_packages%]

    ezpublish_legacy.setup_wizard.configuration_dumper:
        class: %ezpublish_legacy.setup_wizard.configuration_dumper.class%
        arguments:
            - @filesystem
            - %ezpublish_legacy.setup_wizard.configuration_dumper.environments%
            - %kernel.root_dir%
            - %kernel.cache_dir%
            - @ezpublish_legacy.webconfigurator

    # eZ alias for sensio.distribution.webconfigurator to make it available despite Bundle being disabled in prod env
    # uses factory to make sure steps are injected only when service is needed
    ezpublish_legacy.webconfigurator:
        class: %ezpublish_legacy.webconfigurator.class%
        factory_service: ezpublish_legacy.webconfigurator.factory
        factory_method: buildWebConfigurator
        arguments:
            - %kernel.root_dir%

    ezpublish_legacy.webconfigurator.factory:
        class: %ezpublish_legacy.webconfigurator.factory.class%

    # Image alias generator using legacy
    ezpublish_legacy.fieldType.ezimage.variation_service:
        class: %ezpublish_legacy.fieldType.ezimage.variation_service.class%
        arguments: [@ezpublish_legacy.kernel]

    ezpublish_legacy.rest_listener:
        class: %ezpublish_legacy.rest_listener.class%
        arguments: [%ezpublish_rest.csrf_token_intention%]
        tags:
            - { name: kernel.event_subscriber }

    ezpublish_legacy.request_listener:
        class: %ezpublish_legacy.request_listener.class%
        arguments: [@ezpublish.config.resolver, @ezpublish.api.repository, @security.context]
        tags:
            - { name: kernel.event_subscriber }

    ezpublish_legacy.response_listener:
        class: %ezpublish_legacy.response_listener.class%
        tags:
            - { name: kernel.event_subscriber }

    ezpublish_legacy.config_scope_listener:
        class: %ezpublish_legacy.config_scope_listener.class%
        arguments: [@ezpublish_legacy.kernel.lazy_loader]
        tags:
            - { name: kernel.event_subscriber }

    ezpublish_legacy.legacy_kernel_listener:
        class: %ezpublish_legacy.legacy_kernel_listener.class%
        tags:
            - { name: kernel.event_subscriber }

    ezpublish_legacy.legacy_bundles.extension_locator:
        class: %ezpublish_legacy.legacy_bundles.extension_locator.class%
