parameters:
    oro_platform.composer.installed_json: '%kernel.project_dir%/vendor/composer/installed.json'

    oro_platform.collector.template: '@@OroPlatform/Collector/platform.html.twig'

    oro_platform.collect_deprecations: false

    oro_platform.xdebug_warning_command_list:
        - 'cache:warmup'
        - 'cache:clear'
        - 'oro:assets:build'
        - 'oro:platform:update'
        - 'oro:install'

services:
    oro_platform.psr7.http_factory:
        class: GuzzleHttp\Psr7\HttpFactory
    # provide default implementations for PSR-17 based on guzzlehttp/psr7
    Psr\Http\Message\ServerRequestFactoryInterface:
        alias: oro_platform.psr7.http_factory
    Psr\Http\Message\StreamFactoryInterface:
        alias: oro_platform.psr7.http_factory
    Psr\Http\Message\UploadedFileFactoryInterface:
        alias: oro_platform.psr7.http_factory
    Psr\Http\Message\ResponseFactoryInterface:
        alias: oro_platform.psr7.http_factory

    oro_platform.serializer.fix_skip_null_values_array_normalizer:
        class: Oro\Bundle\PlatformBundle\Serializer\Normalizer\FixSkipNullValuesArrayNormalizer
        tags:
            - { name: serializer.normalizer, priority: -1000 } # run after all custom normalizers

    oro_platform.fix_json_status_code_error_renderer:
        class: Oro\Bundle\PlatformBundle\ErrorRenderer\FixJsonStatusCodeErrorRenderer
        decorates: error_renderer.serializer
        arguments:
            - '@.inner'
            - ['application/json', 'application/x-json']

    oro_platform.fos_rest.fix_message_flatten_exception_normalizer:
        class: Oro\Bundle\PlatformBundle\ErrorRenderer\FixMessageFlattenExceptionNormalizer
        decorates: fos_rest.serializer.flatten_exception_normalizer
        arguments:
            - '@.inner'

    oro_platform.service_link.service_locator:
        class: Symfony\Component\DependencyInjection\ServiceLocator
        arguments:
            - []
        tags:
            - { name: container.service_locator }

    oro_platform.version.cache:
        parent: oro.data.cache
        tags:
            - { name: 'cache.pool', namespace: 'oro_platform_version' }

    oro_platform.url.cache:
        parent: oro.data.cache
        tags:
            - { name: 'cache.pool', namespace: 'oro_platform_url' }

    oro_platform.composer.version_helper:
        class: Oro\Bundle\PlatformBundle\Composer\VersionHelper
        arguments:
            - '@oro_platform.version.cache'

    oro_platform.form.url_generator:
        class: 'Oro\Bundle\PlatformBundle\Form\UrlGenerator'
        public: true
        arguments:
            - '@oro_platform.provider.package'
            - '@oro_platform.url.cache'

    oro_platform.provider.package:
        class: 'Oro\Bundle\PlatformBundle\Provider\PackageProvider'

    oro_platform.provider.deployment_variables:
        class: 'Oro\Bundle\PlatformBundle\Provider\DeploymentVariableProvider'
        arguments:
            - '@parameter_bag'

    oro_platform.twig.platform_extension:
        class: Oro\Bundle\PlatformBundle\Twig\PlatformExtension
        public: false
        arguments:
            - '@oro_platform.twig.service_locator'
        tags:
            - { name: twig.extension }

    oro_platform.optional_listeners.manager:
        class: Oro\Bundle\PlatformBundle\Manager\OptionalListenerManager
        public: true
        arguments:
           - []
           - '@service_container'

    oro_platform.event_listener.data_fixtures_listener.abstract:
        class: 'Oro\Bundle\PlatformBundle\EventListener\AbstractDemoDataFixturesListener'
        abstract: true
        arguments:
            - '@oro_platform.optional_listeners.manager'

    oro_platform.event_listener.demo_data_fixtures_listener.abstract:
        parent: oro_platform.event_listener.data_fixtures_listener.abstract
        class: 'Oro\Bundle\PlatformBundle\EventListener\AbstractDemoDataFixturesListener'
        abstract: true

    oro_platform.provider.console.global_options_provider_registry:
        class: Oro\Bundle\PlatformBundle\Provider\Console\GlobalOptionsProviderRegistry
        arguments:
            - !tagged_iterator oro_platform.console.global_options_provider

    oro_platform.provider.console.optional_listeners_global_options_provider:
        class: Oro\Bundle\PlatformBundle\Provider\Console\OptionalListenersGlobalOptionsProvider
        arguments:
            - '@oro_platform.optional_listeners.manager'
        tags:
            - { name: oro_platform.console.global_options_provider }

    oro_platform.event_listener.console.global_options_listener:
        class: Oro\Bundle\PlatformBundle\EventListener\Console\GlobalOptionsListener
        arguments:
            - '@oro_platform.provider.console.global_options_provider_registry'
        tags:
            - { name: kernel.event_listener, event: console.command, method: onConsoleCommand, priority: 250 }

    oro_platform.command_executor:
        class: Oro\Component\PhpUtils\Tools\CommandExecutor\CommandExecutor
        public: true
        arguments:
            - '%kernel.project_dir%/bin/console'
            - '%kernel.environment%'

    oro_platform.collector:
        class: Oro\Bundle\PlatformBundle\Collector\PlatformCollector
        tags:
            - { name: data_collector, template: "%oro_platform.collector.template%", id: oro_platform, priority: -260 }

    oro_platform.twig.service_locator:
        class: Symfony\Component\DependencyInjection\ServiceLocator
        public: false
        arguments:
            - [] # services. Will be set in Oro\Bundle\PlatformBundle\DependencyInjection\Compiler\TwigServiceLocatorPass
        tags:
            - { name: container.service_locator }

    Doctrine\Persistence\ManagerRegistry:
        alias: 'doctrine'

    Doctrine\Inflector\Inflector:
        factory: [ !service { class: Doctrine\Inflector\Rules\English\InflectorFactory }, 'build' ]

    oro_platform.orm.configuration.configurator:
        class: Oro\Bundle\PlatformBundle\Configurator\OrmConfigurationConfigurator
        arguments:
            - '@oro_distribution.handler.application_status'

    # Overrides the service from doctrine to add the configurator that changes the Configuration->autoGenerateProxyClasses option value to true if the application isn't installed
    doctrine.orm.configuration:
        class: '%doctrine.orm.configuration.class%'
        abstract: true
        public: false
        configurator: ['@oro_platform.orm.configuration.configurator', 'configure']

    oro_platform.provider.dbal_type_default_value:
        class: Oro\Bundle\PlatformBundle\Provider\DbalTypeDefaultValueProvider

    oro_platform.event_listener.console.xdebug_listener:
        class: Oro\Bundle\PlatformBundle\EventListener\Console\XdebugListener
        arguments:
            - '%oro_platform.xdebug_warning_command_list%'
        tags:
            - { name: kernel.event_listener, event: console.command, method: onCommandExecute}

    oro_platform.repository.materialized_view_entity:
        alias: Oro\Bundle\PlatformBundle\Entity\Repository\MaterializedViewEntityRepository

    Oro\Bundle\PlatformBundle\Entity\Repository\MaterializedViewEntityRepository:
        parent: oro_entity.abstract_repository
        arguments:
            - 'Oro\Bundle\PlatformBundle\Entity\MaterializedView'
        tags:
            - { name: doctrine.repository_service }

    Oro\Component\DependencyInjection\PgsqlAdvisorySchemaInUrlEnvVarProcessor:
        tags: [container.env_var_processor]
    
    oro_platform.cache.provider.page_request_provider.abstract:
        class: 'Oro\Bundle\PlatformBundle\Provider\AbstractPageRequestProvider'
        arguments:
            - '@router'
            - '@oro_config.manager'
            - '@logger'
        abstract: true

    oro_platform.validator.constraints.when:
        class: Oro\Bundle\PlatformBundle\Validator\Constraints\WhenValidator
        arguments:
            - '@validator.expression_language'
