services:
    oro_api.action_processor_bag:
        class: Oro\Bundle\ApiBundle\Processor\ActionProcessorBag

    oro_api.processor_bag:
        class: Oro\Component\ChainProcessor\ProcessorBag
        public: false
        arguments:
            - '@oro_api.processor_factory'
            - %kernel.debug%
            - '@oro_api.processor_applicable_checker_factory'
            - '@oro_api.processor_iterator_factory'

    oro_api.processor_iterator_factory:
        class: Oro\Bundle\ApiBundle\Processor\OptimizedProcessorIteratorFactory
        public: false

    oro_api.processor_applicable_checker_factory:
        class: Oro\Bundle\ApiBundle\Processor\ProcessorApplicableCheckerFactory
        public: false

    oro_api.processor_factory:
        class: Oro\Component\ChainProcessor\ChainProcessorFactory
        public: false
        calls:
            - [addFactory,  ['@oro_api.simple_processor_factory', 10]]
            - [addFactory,  ['@oro_api.di_processor_factory']]

    oro_api.simple_processor_factory:
        class: Oro\Component\ChainProcessor\SimpleProcessorFactory
        public: false

    oro_api.di_processor_factory:
        class: Oro\Component\ChainProcessor\DependencyInjection\ProcessorFactory
        public: false
        arguments:
            - '@service_container'

    oro_api.criteria_connector:
        class: Oro\Bundle\ApiBundle\Util\CriteriaConnector
        public: false
        arguments:
            - '@oro_api.criteria_normalizer'
            - '@oro_api.criteria_placeholders_resolver'

    oro_api.criteria_normalizer:
        class: Oro\Bundle\ApiBundle\Util\CriteriaNormalizer
        public: false
        arguments:
            - '@oro_api.criteria_placeholders_resolver'

    oro_api.criteria_placeholders_resolver:
        class: Oro\Bundle\ApiBundle\Util\CriteriaPlaceholdersResolver
        public: false

    oro_api.doctrine_helper:
        class: Oro\Bundle\ApiBundle\Util\DoctrineHelper
        public: false
        arguments:
            - '@doctrine'

    oro_api.validation_helper:
        class: Oro\Bundle\ApiBundle\Util\ValidationHelper
        public: false
        arguments:
            - '@validator.mapping.class_metadata_factory'

    oro_api.entity_instantiator:
        class: Oro\Bundle\ApiBundle\Util\EntityInstantiator
        public: false
        arguments:
            - '@oro_api.doctrine_helper'

    oro_api.entity_accessor:
        class: Oro\Component\EntitySerializer\EntityDataAccessor
        public: false

    oro_api.entity_metadata_factory:
        class: Oro\Bundle\ApiBundle\Metadata\EntityMetadataFactory
        public: false
        arguments:
            - '@oro_api.doctrine_helper'

    oro_api.value_normalizer:
        class: Oro\Bundle\ApiBundle\Request\ValueNormalizer
        arguments:
            - '@oro_api.normalize_value.processor'

    oro_api.object_normalizer:
        class: Oro\Bundle\ApiBundle\Normalizer\ObjectNormalizer
        public: false
        arguments:
            - '@oro_api.object_normalizer_registry'
            - '@oro_api.doctrine_helper'
            - '@oro_api.entity_accessor'
            - '@oro_api.entity_serializer.data_transformer'
            - '@oro_api.object_normalizer.config_normalizer'

    oro_api.object_normalizer.config_normalizer:
        class: Oro\Bundle\ApiBundle\Normalizer\ConfigNormalizer
        public: false

    oro_api.object_normalizer_registry:
        class: Oro\Bundle\ApiBundle\Normalizer\ObjectNormalizerRegistry
        public: false
        calls:
            - [addNormalizer,  ['@oro_api.search_item_normalizer', 50]]
            - [addNormalizer,  ['@oro_api.datetime_normalizer']]

    oro_api.datetime_normalizer:
        class: Oro\Bundle\ApiBundle\Normalizer\DateTimeNormalizer
        public: false

    oro_api.search_item_normalizer:
        class: Oro\Bundle\ApiBundle\Normalizer\SearchItemNormalizer
        public: false

    oro_api.customize_loaded_data.processor:
        class: Oro\Bundle\ApiBundle\Processor\CustomizeLoadedDataProcessor
        public: false
        arguments:
            - '@oro_api.processor_bag'
            - customize_loaded_data

    oro_api.customize_form_data.processor:
        class: Oro\Bundle\ApiBundle\Processor\CustomizeFormDataProcessor
        public: false
        arguments:
            - '@oro_api.processor_bag'
            - customize_form_data

    oro_api.resources_provider:
        class: Oro\Bundle\ApiBundle\Provider\ResourcesProvider
        arguments:
            - '@oro_api.collect_resources.processor'
            - '@oro_api.resources_cache'

    oro_api.subresources_provider:
        class: Oro\Bundle\ApiBundle\Provider\SubresourcesProvider
        arguments:
            - '@oro_api.collect_subresources.processor'
            - '@oro_api.resources_provider'
            - '@oro_api.resources_cache'

    oro_api.resources_cache:
        class: Oro\Bundle\ApiBundle\Provider\ResourcesCache
        arguments:
            - '@oro_api.resources_cache.impl'

    oro_api.resources_cache.impl:
        public: false
        parent: oro.cache.abstract
        calls:
            - [ setNamespace, [ 'oro_api_resources' ] ]

    oro_api.listener.update_schema:
        class: Oro\Bundle\ApiBundle\EventListener\ApiSourceListener
        arguments:
            - '@oro_api.resources_cache'
            - '@nelmio_api_doc.extractor.api_doc_extractor'
            - '%oro_api.api_doc.views%'
        tags:
            - { name: kernel.event_listener, event: oro.entity_extend.entity.schema.update, method: clearCache }
            - { name: kernel.event_listener, event: oro_featuretoggle.features.change, method: clearCache }

    oro_api.config_extension_registry:
        class: Oro\Bundle\ApiBundle\Config\ConfigExtensionRegistry
        arguments:
            - 0 # config_max_nesting_level; it is set by Oro\Bundle\ApiBundle\DependencyInjection\OroApiExtension

    oro_api.config_extension.filters:
        class: Oro\Bundle\ApiBundle\Config\FiltersConfigExtension
        public: false
        tags:
            - { name: oro_api.config_extension }

    oro_api.config_extension.sorters:
        class: Oro\Bundle\ApiBundle\Config\SortersConfigExtension
        public: false
        tags:
            - { name: oro_api.config_extension }

    oro_api.config_extension.actions:
        class: Oro\Bundle\ApiBundle\Config\ActionsConfigExtension
        public: false
        arguments:
            - '@oro_api.action_processor_bag'
        tags:
            - { name: oro_api.config_extension }

    oro_api.config_extension.subresources:
        class: Oro\Bundle\ApiBundle\Config\SubresourcesConfigExtension
        public: false
        arguments:
            - '@oro_api.action_processor_bag'
        tags:
            - { name: oro_api.config_extension }

    oro_api.config_extension.feature:
        class: 'Oro\Bundle\ApiBundle\Config\FeatureConfigurationExtension'
        tags:
            - { name: oro_feature.config_extension }

    oro_api.config_bag:
        class: Oro\Bundle\ApiBundle\Provider\ConfigBag
        public: false
        arguments:
            - []

    oro_api.config_loader_factory:
        class: Oro\Bundle\ApiBundle\Config\ConfigLoaderFactory
        public: false
        arguments:
            - '@oro_api.config_extension_registry'

    oro_api.config_provider:
        class: Oro\Bundle\ApiBundle\Provider\ConfigProvider
        arguments:
            - '@oro_api.get_config.processor'

    oro_api.metadata_provider:
        class: Oro\Bundle\ApiBundle\Provider\MetadataProvider
        arguments:
            - '@oro_api.get_metadata.processor'

    oro_api.relation_config_provider:
        class: Oro\Bundle\ApiBundle\Provider\RelationConfigProvider
        arguments:
            - '@oro_api.get_relation_config.processor'

    oro_api.entity_alias_resolver:
        class: Oro\Bundle\EntityBundle\ORM\EntityAliasResolver
        arguments:
            - '@oro_api.entity_alias_loader'
            - '@oro_api.entity_alias_cache'
            - %kernel.debug%
        calls:
            - [ setLogger, [ '@logger' ] ]
        lazy: true

    oro_api.entity_alias_cache:
        parent: oro.cache.abstract
        public: false
        calls:
            - [ setNamespace, [ 'oro_entity_aliases_api' ] ]

    oro_api.entity_alias_loader:
        class: Oro\Bundle\EntityBundle\Provider\EntityAliasLoader
        public: false
        lazy: true
        calls:
            - [ addEntityAliasProvider, [ '@oro_api.entity_alias_provider' ] ]

    oro_api.entity_alias_provider:
        class: Oro\Bundle\ApiBundle\Provider\EntityAliasProvider
        public: false
        arguments:
            - [] # aliases; it is set by Oro\Bundle\ApiBundle\DependencyInjection\OroApiExtension
            - [] # exclusions; it is set by Oro\Bundle\ApiBundle\DependencyInjection\OroApiExtension

    oro_api.entity_exclusion_provider:
        class: Oro\Bundle\ApiBundle\Provider\ChainExclusionProvider
        public: false
        arguments:
            - '@oro_entity.entity_hierarchy_provider.all'
            - [] # include rules; it is set by Oro\Bundle\ApiBundle\DependencyInjection\OroApiExtension

    oro_api.entity_exclusion_provider.config:
        class: Oro\Bundle\EntityBundle\Provider\ConfigExclusionProvider
        public: false
        arguments:
            - '@oro_entity.entity_hierarchy_provider.all'
            - [] # exclude rules; it is set by Oro\Bundle\ApiBundle\DependencyInjection\OroApiExtension
        tags:
            - { name: oro_entity.exclusion_provider.api, priority: 60 }

    oro_api.entity_serializer:
        class: Oro\Component\EntitySerializer\EntitySerializer
        public: false
        arguments:
            - '@oro_api.entity_serializer.doctrine_helper'
            - '@oro_api.entity_accessor'
            - '@oro_api.entity_serializer.data_transformer'
            - '@oro_api.entity_serializer.query_factory'
            - '@oro_api.entity_serializer.field_accessor'
            - '@oro_api.entity_serializer.config_normalizer'
            - '@oro_api.entity_serializer.data_normalizer'
        calls:
            # replace to compiler pass injection ?
            - ["setFieldsFilter", ['@oro_security.serializer.filter_chain']]

    oro_api.entity_serializer.doctrine_helper:
        class: Oro\Component\EntitySerializer\DoctrineHelper
        public: false
        arguments:
            - '@doctrine'

    oro_api.entity_serializer.query_factory:
        class: Oro\Bundle\ApiBundle\Util\AclProtectedQueryFactory
        public: false
        arguments:
            - '@oro_api.entity_serializer.doctrine_helper'
            - '@oro_entity.query_hint_resolver'
        calls:
            - [setAclHelper, ['@oro_security.acl_helper']]

    oro_api.entity_serializer.field_accessor:
        class: Oro\Component\EntitySerializer\FieldAccessor
        public: false
        arguments:
            - '@oro_api.entity_serializer.doctrine_helper'
            - '@oro_api.entity_accessor'

    oro_api.entity_serializer.config_normalizer:
        class: Oro\Bundle\ApiBundle\Util\ConfigNormalizer
        public: false

    oro_api.entity_serializer.data_normalizer:
        class: Oro\Component\EntitySerializer\DataNormalizer
        public: false

    oro_api.entity_serializer.data_transformer:
        class: Oro\Component\EntitySerializer\EntityDataTransformer
        public: false
        arguments:
            - '@service_container'

    oro_api.rest.entity_id_transformer:
        class: Oro\Bundle\ApiBundle\Request\Rest\EntityIdTransformer
        public: false
        arguments:
            - '@oro_api.doctrine_helper'
            - '@oro_api.value_normalizer'

    oro_api.exception_text_extractor:
        class: Oro\Bundle\ApiBundle\Request\ChainExceptionTextExtractor
        public: false

    oro_api.exception_text_extractor.default:
        class: Oro\Bundle\ApiBundle\Request\ExceptionTextExtractor
        public: false
        arguments:
            - %kernel.debug%
            -
                - '\InvalidArgumentException'
                - '\UnexpectedValueException'
                - '\OutOfBoundsException'
                - 'Oro\Bundle\ApiBundle\Exception\ExceptionInterface'
                - 'Symfony\Component\HttpKernel\Exception\HttpExceptionInterface'
                - 'Symfony\Component\PropertyAccess\Exception\ExceptionInterface'
        tags:
            - { name: oro.api.exception_text_extractor, priority: -10 }

    oro_api.rest.document_builder:
        class: Oro\Bundle\ApiBundle\Request\Rest\RestDocumentBuilder
        public: false

    oro_api.rest.error_completer:
        class: Oro\Bundle\ApiBundle\Request\Rest\ErrorCompleter
        public: false
        arguments:
            - '@oro_api.exception_text_extractor'
        lazy: true

    oro_api.json_api.document_builder:
        class: Oro\Bundle\ApiBundle\Request\JsonApi\JsonApiDocumentBuilder
        public: false
        arguments:
            - '@oro_api.value_normalizer'
            - '@oro_api.rest.entity_id_transformer'

    oro_api.json_api.error_completer:
        class: Oro\Bundle\ApiBundle\Request\JsonApi\ErrorCompleter
        public: false
        arguments:
            - '@oro_api.exception_text_extractor'
        lazy: true

    oro_api.json_api.relationship_error_completer:
        class: Oro\Bundle\ApiBundle\Request\JsonApi\RelationshipErrorCompleter
        public: false
        arguments:
            - '@oro_api.exception_text_extractor'
        lazy: true

    oro_api.rest.routing_options_resolver.default:
        class: Oro\Bundle\ApiBundle\ApiDoc\RestRouteOptionsResolver
        public: false
        arguments:
            - '@oro_api.rest.doc_view_detector'
            - '@oro_api.resources_provider'
            - '@oro_api.subresources_provider'
            - '@oro_api.value_normalizer'
        tags:
            - { name: oro_api.routing_options_resolver }

    oro_api.rest.routing_options_resolver:
        class: Oro\Bundle\ApiBundle\ApiDoc\RestChainRouteOptionsResolver
        public: false
        arguments:
            - '@oro_api.rest.doc_view_detector'

    oro_api.rest.doc_handler:
        class: Oro\Bundle\ApiBundle\ApiDoc\RestDocHandler
        public: false
        arguments:
            - '@oro_api.rest.doc_view_detector'
            - '@oro_api.action_processor_bag'
            - '@oro_api.value_normalizer'
        tags:
            - { name: nelmio_api_doc.extractor.handler }

    oro_api.rest.doc_view_detector:
        class: Oro\Bundle\ApiBundle\ApiDoc\RestDocViewDetector
        public: false
        arguments:
            - '@request_stack'

    oro_api.rest.request_type_provider:
        class: Oro\Bundle\ApiBundle\ApiDoc\RestRequestTypeProvider
        public: false
        tags:
            - { name: oro_api.request_type_provider }

    oro_api.listener.dump_api_doc_console_command_listener:
        class: Oro\Bundle\ApiBundle\EventListener\DumpApiDocConsoleCommandListener
        arguments:
            - '@oro_api.rest.doc_view_detector'
        tags:
            - { name: kernel.event_listener, event: console.command, method: onConsoleCommand, priority: 250 }

    oro_api.entity_description_provider:
        class: Oro\Bundle\ApiBundle\ApiDoc\EntityDescriptionProvider
        public: false
        arguments:
            - '@oro_entity.entity_class_name_provider'
            - '@oro_entity_config.provider.entity'
            - '@oro_api.doctrine_helper'
            - '@translator'

    oro_api.resource_doc_provider:
        class: Oro\Bundle\ApiBundle\ApiDoc\ResourceDocProvider
        public: false

    oro_api.filter_factory:
        class: Oro\Bundle\ApiBundle\Filter\ChainFilterFactory
        public: false

    oro_api.filter_factory.default:
        class: Oro\Bundle\ApiBundle\Filter\SimpleFilterFactory
        public: false
        arguments:
            - '@property_accessor'
        tags:
            - { name: oro.api.filter_factory, priority: -10 }

    oro_api.constraint_text_extractor:
        class: Oro\Bundle\ApiBundle\Request\ChainConstraintTextExtractor
        public: false

    oro_api.constraint_text_extractor.default:
        class: Oro\Bundle\ApiBundle\Request\ConstraintTextExtractor
        public: false
        tags:
            - { name: oro.api.constraint_text_extractor, priority: -10 }
