services:
    oro_config.config_bag:
        class: Oro\Bundle\ConfigBundle\Config\ConfigBag
        arguments:
            - [] # config; it is set by Oro\Bundle\ConfigBundle\DependencyInjection\Compiler\SystemConfigurationPass
            - '@service_container'

    oro_config.config_definition_bag:
        class: Oro\Bundle\ConfigBundle\Config\ConfigDefinitionImmutableBag
        public: false
        arguments:
            - [] # settings; they are set by Oro\Bundle\ConfigBundle\DependencyInjection\Compiler\SystemConfigurationPass

    oro_config.cache:
        public: false
        parent: oro.data.cache
        tags:
            - { name: 'cache.pool', namespace: 'oro_config' }

    oro_config.scope_manager.abstract:
        abstract: true
        arguments:
            - '@doctrine'
            - '@oro_config.cache'
            - '@event_dispatcher'
            - '@oro_config.config_bag'

    oro_config.scope.user:
        class: Oro\Bundle\ConfigBundle\Config\UserScopeManager
        public: false
        parent: oro_config.scope_manager.abstract
        calls:
            - [setSecurityContext, [ '@security.token_storage' ]]
        tags:
            - { name: oro_config.scope, scope: user, priority: 255 }

    oro_config.scope.global:
        class: Oro\Bundle\ConfigBundle\Config\GlobalScopeManager
        public: false
        parent: oro_config.scope_manager.abstract
        tags:
            - { name: oro_config.scope, scope: global, priority: -255 }

    # a template definition for scoped config managers
    # actually this service is replaced with an alias to the most priority scoped config manager
    oro_config.manager:
        class: Oro\Bundle\ConfigBundle\Config\ConfigManager
        public: true
        arguments:
            - ~ # scope; it is set by Oro\Bundle\ConfigBundle\DependencyInjection\Compiler\SystemConfigurationPass
            - '@oro_config.config_definition_bag'
            - '@event_dispatcher'
            - '@oro_config.manager.memory_cache'

    oro_config.manager.memory_cache:
        class: Oro\Bundle\CacheBundle\Provider\MemoryCache

    oro_config.event_listener.clear_manager_memory_cache:
        class: Oro\Bundle\ConfigBundle\EventListener\ConfigManagerMemoryCacheClearListener
        arguments:
            - '@oro_config.manager.memory_cache'
        tags:
            - { name: kernel.event_listener, event: oro_config.config_manager_scope_id_change, method: onScopeIdChange }

    Oro\Bundle\ConfigBundle\Config\ConfigManager:
        alias: oro_config.manager

    oro_config.twig.config_extension:
        class: Oro\Bundle\ConfigBundle\Twig\ConfigExtension
        public: false
        arguments:
            - '@oro_platform.twig.service_locator'
        tags:
            - { name: twig.extension }

    oro_config.provider.abstract_provider:
        class: Oro\Bundle\ConfigBundle\Provider\AbstractProvider
        abstract: true
        arguments:
            - '@oro_config.config_bag'
            - '@translator'
            - '@form.factory'
            - '@form.registry'
            - '@security.authorization_checker'
            - '@oro_config.configuration_search_provider.chain'
            - '@oro_featuretoggle.checker.feature_checker'
            - '@event_dispatcher'

    Oro\Bundle\ConfigBundle\Provider\SystemConfigurationFormProvider:
        alias: oro_config.provider.system_configuration.form_provider

    oro_config.provider.system_configuration.form_provider:
        class: Oro\Bundle\ConfigBundle\Provider\SystemConfigurationFormProvider
        public: true
        parent: oro_config.provider.abstract_provider
        lazy: true

    oro_config.form.config_subscriber:
        class: Oro\Bundle\ConfigBundle\Form\EventListener\ConfigSubscriber
        arguments:
          - '@oro_config.user'
          - '@oro_entity.doctrine_helper'

    oro_config.type.form:
        class: Oro\Bundle\ConfigBundle\Form\Type\FormType
        arguments:
            - '@oro_config.form.config_subscriber'
            - '@service_container'
        tags:
            - { name: form.type, alias: oro_config_form_type }

    oro_config.type.form_field:
        class: Oro\Bundle\ConfigBundle\Form\Type\FormFieldType
        tags:
            - { name: form.type, alias: oro_config_form_field_type }

    oro_config.type.parent_scope_checkbox:
        class: Oro\Bundle\ConfigBundle\Form\Type\ParentScopeCheckbox
        tags:
            - { name: form.type, alias: oro_config_parent_scope_checkbox_type }

    oro_config.type.config_checkbox:
        class: Oro\Bundle\ConfigBundle\Form\Type\ConfigCheckbox
        tags:
            - { name: form.type, alias: oro_config_checkbox }

    oro_config.type.config_file:
        class: Oro\Bundle\ConfigBundle\Form\Type\ConfigFileType
        arguments:
            - '@oro_config.form.config_file_data_transformer'
        tags:
            - { name: form.type }

    oro_config.type.url_info_type:
        class: Oro\Bundle\ConfigBundle\Form\Type\UrlInfoType
        arguments:
            - '@router'
        tags:
            - { name: form.type }

    oro_config.form.handler.config:
        class: Oro\Bundle\ConfigBundle\Form\Handler\ConfigHandler
        public: true
        arguments:
            - '@oro_config.global'

    Oro\Bundle\ConfigBundle\Form\Handler\ConfigHandler:
        alias: oro_config.form.handler.config

    oro_config.manager.api:
        class: Oro\Bundle\ConfigBundle\Config\ConfigApiManager
        public: true
        arguments:
            - '@oro_config.provider.system_configuration.form_provider'

    oro_config.form.config_file_data_transformer:
        class: Oro\Bundle\ConfigBundle\Form\DataTransformer\ConfigFileDataTransformer
        arguments:
            - '@oro_entity.doctrine_helper'
            - '@validator'

    oro_config.condition.is_system_config_equal:
        class: Oro\Bundle\ConfigBundle\Condition\IsSystemConfigEqual
        arguments:
            - '@oro_config.manager'
        tags:
            - { name: oro_action.condition, alias: 'is_system_config_equal' }

    oro_config.event_listener.cache_state:
        class: Oro\Bundle\ConfigBundle\EventListener\CacheStateChangeListener
        arguments:
            - '@oro_message_queue.consumption.cache_state'
        tags:
            - { name: kernel.event_listener, event: oro_config.update_after, method: onConfigUpdate }

    oro_config.configuration_search_provider.chain:
        class: Oro\Bundle\ConfigBundle\Provider\ChainSearchProvider
        public: false
        arguments:
            - !tagged_iterator oro_config.configuration_search_provider

    oro_config.configuration_search_provider.group:
        class: Oro\Bundle\ConfigBundle\Provider\GroupSearchProvider
        public: false
        arguments:
            - '@oro_config.config_bag'
            - '@translator'
        tags:
            - { name: oro_config.configuration_search_provider }

    oro_config.configuration_search_provider.field:
        class: Oro\Bundle\ConfigBundle\Provider\FieldSearchProvider
        public: false
        arguments:
            - '@oro_config.config_bag'
            - '@translator'
            - '@oro_config.manager'
        tags:
            - { name: oro_config.configuration_search_provider, priority: -10 }

    oro_config.placeholder.filter:
        class: Oro\Bundle\ConfigBundle\Placeholder\PlaceholderFilter
        public: true
        arguments:
            - "@oro_config.user"
