services:
    oro_website.manager:
        class: 'Oro\Bundle\WebsiteBundle\Manager\WebsiteManager'
        public: true
        arguments:
            - "@doctrine"
            - "@oro_frontend.request.frontend_helper"
            - "@oro_maintenance.maintenance_state"
        calls:
            - ['setMaintenanceRestrictionsChecker', ['@oro_maintenance.maintenance_restrictions_checker']]
        tags:
            - { name: doctrine.event_listener, event: onClear }

    Oro\Bundle\WebsiteBundle\Manager\WebsiteManager:
        alias: 'oro_website.manager'

    oro_website.twig.entity_date_time_extension:
        class: Oro\Bundle\WebsiteBundle\Twig\EntityDateTimeExtension
        public: false
        arguments:
            - '@oro_platform.twig.service_locator'
        tags:
            - { name: twig.extension }

    oro_website.website.manager.api:
        class: 'Oro\Bundle\SoapBundle\Entity\Manager\ApiEntityManager'
        parent: oro_soap.manager.entity_manager.abstract
        arguments:
            - 'Oro\Bundle\WebsiteBundle\Entity\Website'
            - "@doctrine.orm.entity_manager"

    oro_website.website.provider:
        class: 'Oro\Bundle\WebsiteBundle\Provider\WebsiteProvider'
        public: true
        arguments:
            - "@doctrine"

    oro_website.cache.website:
        parent: oro.cache.adapter.array

    oro_website.cacheable_website_provider:
        class: 'Oro\Bundle\WebsiteBundle\Provider\CacheableWebsiteProvider'
        decorates: 'oro_website.website.provider'
        decoration_priority: -255 # the cacheable provider should be at the top of the decoration chain
        arguments:
            - '@.inner'
            - '@oro_website.cache.website'
            - '@security.token_storage'

    oro_website.event_listener.website:
        class: 'Oro\Bundle\WebsiteBundle\EventListener\WebsiteListener'
        arguments:
            - '@oro_website.cacheable_website_provider'
        tags:
            - { name: doctrine.event_listener, event: onFlush, priority: -255 }

    oro_website.model.action.assign_current_website:
        class: 'Oro\Bundle\WebsiteBundle\Model\Action\AssignCurrentWebsite'
        public: false
        arguments:
            - '@oro_action.expression.context_accessor'
            - '@oro_website.manager'
        tags:
            - { name: oro_action.action, alias: assign_current_website }

    oro_website.request_website_provider:
        class: 'Oro\Bundle\WebsiteBundle\Provider\RequestWebsiteProvider'
        arguments:
            - '@request_stack'
            - '@oro_website.manager'

    oro_website.resolver.website_url_resolver.memory_cache:
        parent: oro.cache.provider.memory_cache

    oro_website.resolver.website_url_resolver:
        class: 'Oro\Bundle\WebsiteBundle\Resolver\WebsiteUrlResolver'
        public: true
        arguments:
            - '@oro_config.manager'
            - '@router'
        calls:
            - [setMemoryCacheProvider, ['@oro_website.resolver.website_url_resolver.memory_cache']]

    Oro\Bundle\WebsiteBundle\Resolver\WebsiteUrlResolver:
        alias: oro_website.resolver.website_url_resolver

    oro_website.resolver.website_system_url_resolver.memory_cache:
        parent: oro.cache.provider.memory_cache

    oro_website.resolver.website_system_url_resolver:
        class: 'Oro\Bundle\WebsiteBundle\Resolver\WebsiteUrlResolver'
        arguments:
            - '@oro_config.manager'
            - '@router.default'
        calls:
            - [setMemoryCacheProvider, ['@oro_website.resolver.website_system_url_resolver.memory_cache']]

    oro_website.twig.website_extension:
        class: Oro\Bundle\WebsiteBundle\Twig\WebsiteExtension
        public: false
        arguments:
            - '@oro_platform.twig.service_locator'
        tags:
            - { name: twig.extension }

    oro_website.entity_listener.website:
        class: 'Oro\Bundle\WebsiteBundle\Entity\EntityListener\WebsiteEntityListener'
        public: false
        arguments:
            - '@oro_scope.scope_manager'
        tags:
            - { name: doctrine.orm.entity_listener, entity: 'Oro\Bundle\WebsiteBundle\Entity\Website', event: prePersist }

    oro_website.provider.website_localization:
        class: 'Oro\Bundle\WebsiteBundle\Provider\WebsiteLocalizationProvider'
        arguments:
            - '@oro_config.manager'
            - '@oro_locale.manager.localization'
            - '@oro_entity.doctrine_helper'

    oro_website.asset.base_path_resolver:
        class: Oro\Bundle\WebsiteBundle\Asset\BasePathResolver
        arguments:
            - '@request_stack'

    oro_website.assetic_context:
        class: 'Oro\Bundle\WebsiteBundle\Asset\AssetsContext'
        decorates: assets.context
        arguments:
            - '@request_stack'
        calls:
            - [setBasePathResolver, ['@oro_website.asset.base_path_resolver']]

    oro_website.asset.request_context:
        class: Oro\Bundle\WebsiteBundle\Asset\RequestContext
        factory: [Oro\Bundle\WebsiteBundle\Asset\RequestContext, fromUri]
        arguments:
            - '%router.request_context.base_url%'
            - '%router.request_context.host%'
            - '%router.request_context.scheme%'
            - '%request_listener.http_port%'
            - '%request_listener.https_port%'
        calls:
            - [setParameter, ['_functions', '@?router.expression_language_provider']]
            - [setBasePathResolver, ['@oro_website.asset.base_path_resolver']]

    oro_website.event_listener.assets_request:
        class: Oro\Bundle\WebsiteBundle\EventListener\AssetsRequestListener
        arguments:
            - '@oro_website.asset.request_context'
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onKernelRequest }

    # See usage in Oro\Bundle\WebsiteBundle\DependencyInjection\Compiler\AttachmentUrlGeneratorPass
    oro_website.asset.router:
        parent: router.default
        public: true

    oro_website.provider.url_without_front_controller:
        class: Oro\Bundle\UIBundle\Provider\UrlWithoutFrontControllerProvider
        decorates: oro_ui.provider.url_without_front_controller
        arguments:
            - '@oro_website.asset.router'

    oro_website.website_scope_criteria_provider:
        class: 'Oro\Bundle\WebsiteBundle\Provider\ScopeCriteriaProvider'
        public: false
        arguments:
            - "@oro_website.manager"

    oro_website.event_listener.theme_system_config_form_options_listener:
        class: Oro\Bundle\WebsiteBundle\EventListener\RoutingSystemConfigFormOptionsListener
        tags:
            - { name: kernel.event_listener, event: oro_config.settings_form_options_set, method: onFormOptions }

    oro_website.event_listener.redirect:
        class: 'Oro\Bundle\WebsiteBundle\EventListener\RedirectListener'
        arguments:
            - '@oro_website.manager'
            - '@oro_website.resolver.website_url_resolver'
            - '@oro_frontend.request.frontend_helper'
        tags:
            - { name: kernel.event_listener, event: kernel.request, method: onRequest, priority: 45 }

    oro_website.layout.cache.extension.website:
        class: Oro\Bundle\WebsiteBundle\Layout\Cache\Extension\WebsiteRenderCacheExtension
        arguments:
            - '@oro_website.manager'
        tags: [ layout.cache.extension ]
