parameters:
    # this parameter is set by OroEmbeddedFormExtension
    oro_embedded_form.session_id_field_name: ~
    oro_embedded_form.csrf_token_lifetime: ~

services:
    oro_embedded_form.form_type.available_embedded_form:
        class: Oro\Bundle\EmbeddedFormBundle\Form\Type\AvailableEmbeddedFormType
        arguments:
            - '@oro_embedded_form.manager'
        tags:
            - { name: form.type, alias: oro_available_embedded_forms }

    Oro\Bundle\EmbeddedFormBundle\Manager\EmbeddedFormManager:
        alias: oro_embedded_form.manager

    oro_embedded_form.manager:
        class: Oro\Bundle\EmbeddedFormBundle\Manager\EmbeddedFormManager
        public: true
        arguments:
            - '@form.registry'
            - '@form.factory'

    oro_embedded_form.back_link.twig.extension:
        class: Oro\Bundle\EmbeddedFormBundle\Twig\BackLinkExtension
        public: false
        arguments:
            - '@oro_platform.twig.service_locator'
        tags:
            - { name: twig.extension }

    oro_embedded_form.form_type:
        class: Oro\Bundle\EmbeddedFormBundle\Form\Type\EmbeddedFormType
        tags:
            - { name: form.type, alias: embedded_form }

    oro_embedded_form.layout_factory_builder:
        synthetic: true

    oro_embedded_form.layout_manager:
        synthetic: true

    Oro\Bundle\EmbeddedFormBundle\Manager\EmbedFormLayoutManager:
        alias: oro_embedded_form.embed_form_layout_manager

    oro_embedded_form.embed_form_layout_manager:
        class: Oro\Bundle\EmbeddedFormBundle\Manager\EmbedFormLayoutManager
        public: true
        arguments:
            - '@oro_embedded_form.layout_manager'
        calls:
            - [setSessionIdProvider, ['@oro_embedded_form.session_id_provider']]
            - [setSessionIdFieldName, ['%oro_embedded_form.session_id_field_name%']]

    oro_embedded_form.csrf_token_storage.decorator:
        class: Oro\Bundle\EmbeddedFormBundle\Manager\CsrfTokenStorageDecorator
        public: false
        decorates: security.csrf.token_storage
        arguments:
            - '@.inner'
            - '@oro_embedded_form.csrf_token_storage'
            - '@request_stack'
            - 'oro_embedded_form_submit'

    oro_embedded_form.csrf_token_storage:
        class: Oro\Bundle\EmbeddedFormBundle\Manager\CsrfTokenStorage
        public: false
        arguments:
            - ~ # the cache service is set by OroEmbeddedFormExtension
            - '%oro_embedded_form.csrf_token_lifetime%'
            - '@oro_embedded_form.session_id_provider'

    oro_embedded_form.session_id_provider:
        class: Oro\Bundle\EmbeddedFormBundle\Manager\SessionIdProvider
        public: false
        arguments:
            - '@request_stack'
            - '%oro_embedded_form.session_id_field_name%'

    oro_embedded_form.layout.block_type.success_message:
        parent: oro_layout.block_type.abstract_configurable
        calls:
            - [setOptionsConfig, [{message: {default: ''}, form_id: {default: null}}]]
            - [setName, ['embed_form_success']]
        tags:
             - { name: layout.block_type, alias: embed_form_success }

    oro_embedded_form.form_layout_builder:
        class: Oro\Bundle\EmbeddedFormBundle\Layout\Form\GroupingFormLayoutBuilder
        calls:
            - [addSimpleFormTypes, [['choice', 'datetime', 'date', 'time']]]

    oro_embedded_form.layout_context_configurator.form:
        class: Oro\Bundle\EmbeddedFormBundle\Layout\Extension\FormContextConfigurator
        arguments:
            - '@service_container'
        tags:
            - { name: layout.context_configurator, priority: -100 }

    oro_embedded_form.csrf_token_cache:
        class: Symfony\Component\Cache\Adapter\PhpFilesAdapter
        arguments:
            - ''
            - '%oro_embedded_form.csrf_token_lifetime%'
            - '%kernel.cache_dir%/security/embedded_form'
