parameters:
    # The names of API views that are available for the storefront
    # they are set by Oro\Bundle\FrontendBundle\DependencyInjection\OroFrontendExtension
    oro_frontend.api_doc.views: []

    # The name of default API view for the storefront
    # it is set by Oro\Bundle\FrontendBundle\DependencyInjection\OroFrontendExtension
    oro_frontend.api_doc.default_view: ~

services:
    oro_frontend.api.resource_checker:
        class: Oro\Bundle\ApiBundle\Provider\ResourceChecker
        arguments:
            - '@oro_featuretoggle.checker.feature_checker'
            - '@oro_frontend.api.resource_checker_config_provider'
            - 'frontend_api_resources'

    oro_frontend.api.resource_checker_config_provider:
        class: Oro\Bundle\ApiBundle\Provider\ResourceCheckerConfigProvider
        arguments:
            - '%kernel.cache_dir%/oro/feature_frontend_api_resources.php'

    oro_frontend.api.config_extension.feature:
        class: Oro\Bundle\ApiBundle\Config\Extension\FeatureConfigurationExtension
        arguments:
            - '@oro_api.action_processor_bag'
            - '@oro_frontend.api.resource_checker_config_provider'
            - 'frontend_api_resources'
            - 'A list of entity FQCNs that are available as the storefront API resources.'
        tags:
            - { name: oro_feature.config_extension }

    oro_frontend.api.resource_checker.frontend:
        abstract: true
        tags:
            -
                name: oro.api.resource_checker
                requestType: frontend
                resourceType: frontend_api_resources
                resourceChecker: oro_frontend.api.resource_checker
                resourceCheckerConfigProvider: oro_frontend.api.resource_checker_config_provider

    oro_frontend.api.rest.request_handler:
        class: Oro\Bundle\ApiBundle\Request\Rest\RequestHandler
        arguments:
            - '@oro_frontend.api.rest.request_action_handler'

    oro_frontend.api.rest.request_action_handler:
        parent: oro_api.rest.request_action_handler
        arguments:
            index_0: ['rest', 'frontend']

    oro_frontend.api.rest.routing_options_resolver:
        parent: oro_api.rest.routing_options_resolver
        arguments:
            index_0: 'frontend_rest_api'
            index_1: '@oro_frontend.api.rest.routes'
            index_2: '@oro_frontend.api.rest.action_mapper'
        tags:
            - { name: oro.api.routing_options_resolver, view: frontend_rest_json_api }

    oro_frontend.api.rest.doc_handler:
        parent: oro_api.rest.doc_handler
        arguments:
            index_0: 'frontend_rest_api'
        tags:
            - { name: nelmio_api_doc.extractor.handler }

    oro_frontend.api.rest.cors_settings:
        class: Oro\Bundle\ApiBundle\Request\Rest\CorsSettings
        arguments:
            - 0 # preflightMaxAge. It is set by Oro\Bundle\FrontendBundle\DependencyInjection\OroFrontendExtension
            - [] # allowedOrigins. They are set by Oro\Bundle\FrontendBundle\DependencyInjection\OroFrontendExtension
            - false # isCredentialsAllowed. It is set by Oro\Bundle\FrontendBundle\DependencyInjection\OroFrontendExtension
            - [] # allowedHeaders. They are set by Oro\Bundle\FrontendBundle\DependencyInjection\OroFrontendExtension
            - [] # exposableHeaders. They are set by Oro\Bundle\FrontendBundle\DependencyInjection\OroFrontendExtension

    oro_frontend.api.rest.routes:
        class: Oro\Bundle\ApiBundle\Request\Rest\RestRoutes
        arguments:
            - 'oro_frontend_rest_api_item'
            - 'oro_frontend_rest_api_list'
            - 'oro_frontend_rest_api_subresource'
            - 'oro_frontend_rest_api_relationship'
        tags:
            - { name: oro.api.rest_routes, requestType: frontend&rest }

    oro_frontend.api.rest.action_mapper:
        class: Oro\Bundle\ApiBundle\ApiDoc\RestActionMapper
        arguments:
            - '@oro_frontend.api.rest.routes'

    oro_frontend.api.rest.update_list_body_listener:
        class: Oro\Bundle\ApiBundle\EventListener\UpdateListBodyListenerDecorator
        decorates: 'fos_rest.body_listener'
        arguments:
            - '@.inner'
            - '@oro_frontend.api.rest.routes'

    oro_frontend.api.rest.doc_url_generator:
        class: Oro\Bundle\FrontendBundle\Api\ApiDoc\RestDocUrlGenerator
        decorates: oro_api.rest.doc_url_generator
        arguments:
            - '@.inner'
            - '@router'
            - '%oro_frontend.api_doc.views%'
            - '%oro_frontend.api_doc.default_view%'

    oro_frontend.api_doc.open_api.name_provider:
        class: Oro\Bundle\FrontendBundle\Api\ApiDoc\OpenApi\Provider\OpenApiSpecificationNameProvider
        decorates: oro_api.api_doc.open_api.name_provider
        arguments:
            - '@.inner'
            - '@oro_api.rest.doc_view_detector'
            - '@translator'

    # default HTML formatter for frontend API views
    # it should be a separate instance because the lists of frontend and backend API views are different
    # see Oro\Bundle\FrontendBundle\DependencyInjection\Compiler\FrontendApiDocPass
    # and Oro\Bundle\FrontendBundle\DependencyInjection\OroFrontendExtension::setDefaultHtmlFormatterForFrontendApiViews
    oro_frontend.api_doc.formatter.html_formatter:
        parent: oro_api.api_doc.formatter.html_formatter

    oro_frontend.api.resource_type_resolver:
        class: Oro\Bundle\FrontendBundle\Api\ChainResourceTypeResolver
        arguments:
            - [] # resolvers
            - ~ # service locator
            - '@oro_api.request_expression_matcher'

    oro_frontend.api.resource_api_url_resolver:
        class: Oro\Bundle\FrontendBundle\Api\ChainResourceApiUrlResolver
        arguments:
            - [] # resolvers
            - ~ # service locator
            - '@oro_api.request_expression_matcher'

    oro_frontend.api.localized_fallback_value_extractor:
        class: Oro\Bundle\LocaleBundle\Api\LocalizedFallbackValueExtractor

    oro_frontend.api.localized_fallback_value_completer:
        class: Oro\Bundle\LocaleBundle\Api\LocalizedFallbackValueCompleter
        tags:
            - { name: oro.api.custom_data_type_completer, requestType: frontend }

    oro_frontend.api.compute_localized_fallback_values:
        class: Oro\Bundle\LocaleBundle\Api\Processor\ComputeLocalizedFallbackValues
        arguments:
            - '@oro_api.doctrine_helper'
            - '@oro_locale.helper.localization'
            - '@oro_frontend.api.localized_fallback_value_extractor'
        tags:
            - { name: oro.api.processor, action: customize_loaded_data, requestType: frontend, collection: true }

    oro_frontend.api.get_config.exclude_custom_fields_by_default:
        class: Oro\Bundle\ApiBundle\Processor\GetConfig\ExcludeCustomFieldsByDefault
        tags:
            - { name: oro.api.processor, action: get_config, extra: '!identifier_fields_only', requestType: frontend, priority: -7 }

    oro_frontend.api.rest.cors.set_allow_origin:
        class: Oro\Bundle\ApiBundle\Processor\Shared\Rest\SetCorsAllowOrigin
        arguments:
            - '@oro_frontend.api.rest.cors_settings'
        tags:
            - { name: oro.api.processor, action: get, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: get_list, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: delete, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: delete_list, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: create, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: update, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: get_subresource, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: delete_subresource, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: add_subresource, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: update_subresource, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: get_relationship, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: delete_relationship, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: add_relationship, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: update_relationship, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: unhandled_error, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }
            - { name: oro.api.processor, action: options, group: normalize_result, requestType: frontend&rest, cors: true, priority: -235 }

    oro_frontend.api.rest.cors.set_allow_and_expose_headers:
        class: Oro\Bundle\ApiBundle\Processor\Shared\Rest\SetCorsAllowAndExposeHeaders
        arguments:
            - '@oro_frontend.api.rest.cors_settings'
        tags:
            - { name: oro.api.processor, action: get, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: get_list, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: delete, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: delete_list, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: create, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: update, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: get_subresource, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: delete_subresource, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: add_subresource, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: update_subresource, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: get_relationship, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: delete_relationship, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: add_relationship, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: update_relationship, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: unhandled_error, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }
            - { name: oro.api.processor, action: options, group: normalize_result, requestType: frontend&rest, cors: true, priority: -240 }

    oro_frontend.api.options.rest.cors.set_max_age:
        class: Oro\Bundle\ApiBundle\Processor\Options\Rest\SetCorsMaxAge
        arguments:
            - '@oro_frontend.api.rest.cors_settings'
        tags:
            - { name: oro.api.processor, action: options, group: normalize_result, requestType: frontend&rest, cors: true, priority: -242 }

    oro_frontend.api.options.rest.set_cache_control:
        class: Oro\Bundle\ApiBundle\Processor\Options\Rest\SetCacheControl
        arguments:
            - '@oro_frontend.api.rest.cors_settings'
        tags:
            - { name: oro.api.processor, action: options, group: normalize_result, requestType: frontend&rest, priority: -245 }
