services:
    oro_api.create.processor:
        class: Oro\Bundle\ApiBundle\Processor\CreateProcessor
        arguments:
            - '@oro_api.processor_bag'
            - create
            - '@oro_api.config_provider'
            - '@oro_api.metadata_provider'

    #
    # initialize
    #

    oro_api.create.initialize_config_extras:
        class: Oro\Bundle\ApiBundle\Processor\Create\InitializeConfigExtras
        tags:
            - { name: oro.api.processor, action: create, group: initialize, priority: 10 }

    #
    # resource_check
    #

    #
    # normalize_input
    #

    oro_api.create.json_api.validate_request_data:
        class: Oro\Bundle\ApiBundle\Processor\Create\JsonApi\ValidateRequestData
        arguments:
            - '@oro_api.value_normalizer'
        tags:
            - { name: oro.api.processor, action: create, group: normalize_input, requestType: json_api, priority: 90 }

    oro_api.create.json_api.extract_entity_id:
        class: Oro\Bundle\ApiBundle\Processor\Create\JsonApi\ExtractEntityId
        tags:
            - { name: oro.api.processor, action: create, group: normalize_input, requestType: json_api, priority: -40 }

    oro_api.create.normalize_entity_id:
        class: Oro\Bundle\ApiBundle\Processor\Create\NormalizeEntityId
        arguments:
            - '@oro_api.entity_id_transformer_registry'
        tags:
            - { name: oro.api.processor, action: create, group: normalize_input, priority: -110 }

    #
    # security_check
    #

    oro_api.create.validate_entity_type_access:
        class: Oro\Bundle\ApiBundle\Processor\Shared\ValidateEntityTypeAccess
        arguments:
            - '@security.authorization_checker'
            - '@oro_api.doctrine_helper'
            - '@oro_security.acl.group_provider.chain'
            - CREATE
        tags:
            - { name: oro.api.processor, action: create, group: security_check, priority: 10 }

    #
    # load_data
    #

    oro_api.create.load_upsert_entity:
        class: Oro\Bundle\ApiBundle\Processor\Create\JsonApi\LoadUpsertEntity
        arguments:
            - '@oro_api.doctrine_helper'
            - '@oro_api.acl_protected_entity_loader'
            - '@oro_api.upsert_criteria_builder'
            - '@oro_api.entity_id_helper'
        tags:
            - { name: oro.api.processor, action: create, group: load_data, requestType: json_api, priority: -5 }

    oro_api.create.create_entity:
        class: Oro\Bundle\ApiBundle\Processor\Create\CreateEntity
        arguments:
            - '@oro_api.doctrine_helper'
            - '@oro_api.entity_loader'
            - '@oro_api.entity_instantiator'
        tags:
            - { name: oro.api.processor, action: create, group: load_data, priority: -10 }

    oro_api.create.set_entity_id:
        class: Oro\Bundle\ApiBundle\Processor\Create\SetEntityId
        arguments:
            - '@oro_api.entity_id_helper'
        tags:
            - { name: oro.api.processor, action: create, group: load_data, priority: -20 }

    #
    # data_security_check
    #

    #
    # transform_data
    #

    #
    # save_data
    #

    oro_api.create.persist_entity:
        class: Oro\Bundle\ApiBundle\Processor\Create\PersistEntity
        arguments:
            - '@oro_api.doctrine_helper'
        tags:
            - { name: oro.api.processor, action: create, group: save_data, priority: -8 }

    oro_api.create.save_entity:
        class: Oro\Bundle\ApiBundle\Processor\Create\SaveEntity
        arguments:
            - '@oro_api.doctrine_helper'
            - '@oro_api.save_data_handler'
        tags:
            - { name: oro.api.processor, action: create, group: save_data, priority: -10 }

    oro_api.create.set_entity_id_to_context:
        class: Oro\Bundle\ApiBundle\Processor\Create\SetEntityIdToContext
        tags:
            - { name: oro.api.processor, action: create, group: save_data, priority: -20 }

    #
    # normalize_data
    #

    oro_api.create.load_normalized_entity:
        class: Oro\Bundle\ApiBundle\Processor\Shared\LoadNormalizedEntity
        arguments:
            - '@oro_api.action_processor_bag'
            - true # prevent loading of the entity by the "get" action and use the entity from the current context
        tags:
            - { name: oro.api.processor, action: create, group: normalize_data, priority: -10 }

    #
    # finalize
    #

    oro_api.create.rest.set_location_header:
        class: Oro\Bundle\ApiBundle\Processor\Create\Rest\SetLocationHeader
        arguments:
            - '@oro_api.rest.routes_registry'
            - '@router'
            - '@oro_api.value_normalizer'
            - '@oro_api.entity_id_transformer_registry'
        tags:
            - { name: oro.api.processor, action: create, group: finalize, requestType: rest, priority: -10 }

    #
    # normalize_result
    #

    oro_api.create.rest.remove_location_header:
        class: Oro\Bundle\ApiBundle\Processor\Create\Rest\RemoveLocationHeader
        tags:
            - { name: oro.api.processor, action: create, group: normalize_result, requestType: rest, priority: 100 }
