services:
    oro_layout.layout.service_locator:
        class: Symfony\Component\DependencyInjection\ServiceLocator
        public: false
        arguments:
            - [] # services. Will be set in Oro\Bundle\LayoutBundle\DependencyInjection\Compiler\ConfigurationPass
        tags:
            - { name: container.service_locator }

    oro_layout.extension:
        public: false
        class: Oro\Component\Layout\Extension\DependencyInjection\DependencyInjectionExtension
        arguments:
            - '@oro_layout.layout.service_locator'
            - {} # types
            - {} # type extensions
            - {} # layout updates
            - {} # context configurators
            - {} # data providers

    oro_layout.cache.block_type_extension:
        class: Oro\Bundle\LayoutBundle\Layout\Extension\CacheBlockTypeExtension
        tags:
            - {name: layout.block_type_extension,  alias: block, priority: 256}

    oro_layout.cache.render_cache:
        class: Oro\Bundle\LayoutBundle\Cache\RenderCache
        arguments:
            - '@cache.oro_layout.render'
            - '@oro_layout.cache.metadata_provider'
            - '@request_stack'
            - !tagged_iterator layout.cache.extension

    oro_layout.cache.extension.localization:
        class: Oro\Bundle\LayoutBundle\Cache\Extension\LocalizationRenderCacheExtension
        arguments:
            - '@oro_locale.provider.current_localization'
        tags: [layout.cache.extension]

    oro_layout.cache.extension.theme:
        class: Oro\Bundle\LayoutBundle\Cache\Extension\ThemeRenderCacheExtension
        arguments:
            - '@oro_layout.layout_context_stack'
        tags: [layout.cache.extension]

    oro_layout.cache.metadata_provider.default:
        class: Oro\Bundle\LayoutBundle\Cache\Metadata\DefaultCacheMetadataProvider

    oro_layout.cache.metadata_provider:
        class: Oro\Bundle\LayoutBundle\Cache\Metadata\CacheMetadataProvider
        arguments:
            - '@oro_layout.cache.metadata_provider.default'
            - !tagged_iterator layout.cache.metadata_provider
            - '@logger'
            - '%kernel.debug%'
        tags:
            - { name: monolog.logger, channel: oro_layout.cache }
            - { name: kernel.reset, method: reset }

    oro_layout.cache.placeholder_renderer:
        class: Oro\Bundle\LayoutBundle\Cache\PlaceholderRenderer
        arguments:
            - '@oro_layout.layout_manager'
            - '@oro_layout.layout_context_stack'
            - '@logger'
        tags:
            - { name: monolog.logger, channel: oro_layout.cache }
            - { name: kernel.reset, method: reset }

    oro_layout.layout_factory_builder:
        class: Oro\Bundle\LayoutBundle\Layout\CacheLayoutFactoryBuilder
        arguments:
            - '@oro_layout.layout_context_stack'
            - '@oro_layout.processor.expression'
            - '@oro_layout.cache.render_cache'
            - '@oro_layout.cache.metadata_provider'
            - '@event_dispatcher'
            - '@oro_layout.cache.block_view_cache'
        calls:
            - [addExtension, ['@oro_layout.extension']]
            - [addExtension, ['@oro_layout.theme_extension']]
            - [setDefaultRenderer, ['%oro_layout.templating.default%']]
            - [setDebug, ['%kernel.debug%']]

    oro_layout.layout_manager:
        class: 'Oro\Bundle\LayoutBundle\Layout\LayoutManager'
        arguments:
            - '@oro_layout.layout_factory_builder'

    Oro\Bundle\LayoutBundle\Layout\LayoutManager:
        alias: oro_layout.layout_manager

    layout:
        alias: oro_layout.layout_manager

    oro_layout.text.helper:
        class: Oro\Component\Layout\Templating\TextHelper
        arguments:
            - '@translator'

    oro_layout.layout_context_configurator.application:
        class: Oro\Bundle\LayoutBundle\Layout\Extension\ApplicationContextConfigurator
        arguments:
            - '@kernel'
        tags:
            - { name: layout.context_configurator }

    oro_layout.layout_context_configurator.action:
        class: Oro\Bundle\LayoutBundle\Layout\Extension\ActionContextConfigurator
        tags:
            - { name: layout.context_configurator, priority: -100 }

    oro_layout.layout_context_configurator.data:
        class: Oro\Bundle\LayoutBundle\Layout\Extension\DataContextConfigurator
        tags:
            - { name: layout.context_configurator, priority: -100 }

    oro_layout.layout_context_configurator.route:
        class: Oro\Bundle\LayoutBundle\Layout\Extension\RouteContextConfigurator
        arguments:
            - '@request_stack'
        tags:
            - { name: layout.context_configurator, priority: -100 }

    oro_layout.layout_context_configurator.expression:
        class: Oro\Bundle\LayoutBundle\Layout\Extension\ExpressionContextConfigurator
        tags:
            - { name: layout.context_configurator }

    oro_layout.layout_context_configurator.last_modification_date:
        class: Oro\Bundle\LayoutBundle\Layout\Extension\LastModifiedDateContextConfigurator
        arguments:
            - '@oro_layout.theme_extension.resource_provider.last_modification_date'
        tags:
            - { name: layout.context_configurator }

    oro_layout.layout_context_configurator.is_xml_http_request:
        class: Oro\Bundle\LayoutBundle\Layout\Extension\XmlHttpRequestConfigurator
        arguments:
            - '@request_stack'
        tags:
            - { name: layout.context_configurator }

    oro_layout.block_type_extension.data_collector:
        class: Oro\Bundle\LayoutBundle\Layout\Block\Extension\DataCollectorExtension
        arguments:
            - '@oro_layout.profiler.layout_data_collector'
        tags:
            - { name: layout.block_type_extension, alias: block, priority: 300 }

    oro_layout.expression.encoder_registry:
        class: Oro\Component\Layout\ExpressionLanguage\Encoder\ExpressionEncoderRegistry
        arguments:
            - !abstract '$encoders defined in Oro\Bundle\LayoutBundle\DependencyInjection\Compiler\ExpressionCompilerPass'

    oro_layout.expression_language.expression_manipulator:
        class: Oro\Component\Layout\ExpressionLanguage\ExpressionManipulator

    oro_layout.expression_language.expression_validator:
        class: Symfony\Component\Validator\Constraints\ExpressionLanguageSyntaxValidator
        arguments:
            - '@oro_layout.expression_language'
        tags:
            - { name: validator.constraint_validator, alias: oro_layout.expression_language.expression_validator }

    oro_layout.expression.json_encoder:
        class: Oro\Component\Layout\ExpressionLanguage\Encoder\JsonExpressionEncoder
        arguments:
            - '@oro_layout.expression_language.expression_manipulator'
        tags:
            - { name: layout.expression.encoder, format: json }

    oro_layout.processor.expression:
        class: Oro\Bundle\LayoutBundle\Layout\CacheExpressionProcessor
        arguments:
            - '@oro_layout.expression_language'
            - '@oro_layout.expression.encoder_registry'
            - '@oro_layout.cache.render_cache'

    oro_layout.provider.image_type:
        class: Oro\Bundle\LayoutBundle\Provider\ImageTypeProvider
        arguments:
            - '@oro_layout.theme_manager'

    Oro\Bundle\LayoutBundle\Provider\ImageTypeProvider:
        alias: oro_layout.provider.image_type

    oro_layout.helper:
        class: Oro\Bundle\LayoutBundle\Request\LayoutHelper
        public: true
        arguments:
            - '@request_stack'

    oro_layout.imports_storage:
        class: Doctrine\Common\Collections\ArrayCollection
        public: false

    oro_layout.layout_context_stack:
        class: Oro\Bundle\LayoutBundle\Layout\Context\LayoutContextStack
        arguments:
            - '@event_dispatcher'

    oro_layout.cache_warmer.layout_updates:
        class: Oro\Bundle\LayoutBundle\Cache\LayoutUpdatesCacheWarmer
        arguments:
            - '@oro_layout.loader'
            - '@kernel'
            - '@oro_layout.layout_factory_builder'
            - '@oro_layout.expression_language.compiled_cache_warmer'
        tags:
            - { name: kernel.cache_warmer }

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

    oro_layout.expression_language:
        class: Symfony\Component\ExpressionLanguage\ExpressionLanguage
        arguments:
            - '@oro_layout.expression_language.cache'
            - []

    oro_layout.data_provider.asset:
        class: Oro\Bundle\LayoutBundle\Layout\DataProvider\AssetProvider
        arguments:
            - '@assets.packages'
        tags:
            - { name: layout.data_provider, alias: asset }

    oro_layout.loader.image_filter:
        class: Oro\Bundle\LayoutBundle\Loader\ImageFilterLoader
        arguments:
            - '@oro_layout.provider.image_type'
            - '@liip_imagine.filter.configuration'
            - '@oro_entity.doctrine_helper'

    oro_layout.block_view_serializer:
        class: Symfony\Component\Serializer\Serializer
        arguments: [{}, {'json': '@oro_layout.block_view_serializer.json_encoder'}]

    oro_layout.block_view_serializer.json_encoder:
        class: Symfony\Component\Serializer\Encoder\JsonEncoder

    oro_layout.block_view_serializer.type_name_converter:
        class: Oro\Bundle\LayoutBundle\Layout\Serializer\TypeNameConverter
        arguments:
            - []

    oro_layout.block_view_serializer.block_view_normalizer:
        class: Oro\Bundle\LayoutBundle\Layout\Serializer\BlockViewNormalizer
        arguments:
            - '@oro_layout.block_view_serializer.block_view_vars_normalizer'
            - '@oro_layout.block_view_serializer.type_name_converter'
        tags:
            - { name: layout.block_view_serializer.normalizer }

    oro_layout.block_view_serializer.block_view_vars_normalizer:
        class: Oro\Bundle\LayoutBundle\Layout\Serializer\BlockViewVarsNormalizer

    oro_layout.expression_language.compiled_cache:
        class: Oro\Component\Layout\ExpressionLanguage\ExpressionLanguageCache
        arguments:
            - '%oro_layout.expression_language_cache_file%'
            - '@logger'

    oro_layout.block_view_serializer.expression_normalizer:
        class: Oro\Bundle\LayoutBundle\Layout\Serializer\ExpressionNormalizer
        arguments:
            - '@oro_layout.expression_language.compiled_cache'
        tags:
            - { name: layout.block_view_serializer.normalizer }

    oro_layout.option_value_bag_normaizer:
        class: Oro\Bundle\LayoutBundle\Layout\Serializer\OptionValueBagNormalizer
        tags:
            - { name: layout.block_view_serializer.normalizer }

    oro_layout.provider.property_accessor:
        class: 'Oro\Bundle\LayoutBundle\Layout\DataProvider\PropertyAccessDataProvider'
        arguments:
            - '@property_accessor'
        tags:
            - { name: layout.data_provider, alias: property_accessor }

    oro_layout.layout.data_provider.filtered_image.abstract:
        class: 'Oro\Bundle\LayoutBundle\Layout\DataProvider\FilteredImageProvider'
        public: false
        abstract: true

    oro_layout.provider.abstract_form:
        abstract: true
        class: 'Oro\Bundle\LayoutBundle\Layout\DataProvider\AbstractFormProvider'
        arguments:
            - '@form.factory'
            - '@router'

    oro_layout.method_phpdoc_extractor:
        class: Oro\Bundle\LayoutBundle\Command\Util\MethodPhpDocExtractor
        public: false

    oro_layout.loader.image_filter.link:
        tags:
            - { name: oro_service_link, service: oro_layout.loader.image_filter }

    oro_layout.loader.imagine_filter_configuration_decorator:
        class: Oro\Bundle\LayoutBundle\Loader\ImagineFilterConfigurationDecorator
        decorates: liip_imagine.filter.configuration
        arguments:
            - '@.inner'
            - '@oro_layout.loader.image_filter.link'

    oro_layout.expression_language_provider.instanceof:
        class: 'Oro\Bundle\LayoutBundle\Layout\ExpressionLanguageProvider\InstanceofExpressionFunctionProvider'
        tags:
            - { name: layout.expression_language_provider }

    oro_layout.cache_warmer.pages_cache_warmer:
        class: Oro\Bundle\LayoutBundle\Cache\PageCacheWarmer
        arguments:
            - !tagged_iterator warmup_page_request_provider
            - '@http_kernel'
            - '@logger'
        tags:
            - { name: kernel.cache_warmer, priority: -2000 } # Warming caches for pages should be called at the end
