services:
    oro_attachment.form.type:
        class: Oro\Bundle\AttachmentBundle\Form\Type\AttachmentType
        tags:
            - { name: form.type, alias: oro_attachment }

    oro_attachment.form.type.file_config:
        class: Oro\Bundle\AttachmentBundle\Form\Type\FileConfigType
        arguments:
            - '@oro_entity_config.config_manager'
        tags:
            - { name: form.type, alias: oro_attachment_file_config }

    oro_attachment.form.type.file:
        class: Oro\Bundle\AttachmentBundle\Form\Type\FileType
        arguments:
            - '@oro_attachment.tools.external_file_factory'
        calls:
            - [setEventSubscriber,  ['@oro_attachment.form.file_subscriber']]
        tags:
            - { name: form.type, alias: oro_file }
            - { name: oro.api.form.type, alias: file }

    oro_attachment.form.type.image:
        class: Oro\Bundle\AttachmentBundle\Form\Type\ImageType
        tags:
            - { name: form.type, alias: oro_image }

    oro_attachment.form.type.external_file:
        class: Oro\Bundle\AttachmentBundle\Form\Type\ExternalFileType
        arguments:
            - '@oro_attachment.form.data_transformer.external_file_transformer'
        tags:
            - { name: form.type }

    oro_attachment.form.data_transformer.external_file_transformer:
        class: Oro\Bundle\AttachmentBundle\Form\DataTransformer\ExternalFileTransformer
        shared: false
        arguments:
            - '@oro_attachment.validator.file_config_validator'
            - '@oro_attachment.tools.external_file_factory'

    oro_attachment.form.type.mime_type_config.file:
        class: Oro\Bundle\AttachmentBundle\Form\Type\FileMimeTypeConfigType
        arguments:
            - '%oro_attachment.upload_file_mime_types%'
        tags:
            - { name: form.type, alias: oro_attachment_file_mime_type_config }

    oro_attachment.form.type.mime_type_config.image:
        class: Oro\Bundle\AttachmentBundle\Form\Type\ImageMimeTypeConfigType
        arguments:
            - '%oro_attachment.upload_image_mime_types%'
        tags:
            - { name: form.type, alias: oro_attachment_image_mime_type_config }

    oro_attachment.form.file_subscriber:
        class: Oro\Bundle\AttachmentBundle\Form\EventSubscriber\FileSubscriber
        arguments:
            - '@oro_attachment.validator.file_config_validator'

    oro_attachment.validator.file_config_validator:
        class: Oro\Bundle\AttachmentBundle\Validator\ConfigFileValidator
        arguments:
            - '@validator'
            - '@oro_attachment.provider.file_constraints'

    Oro\Bundle\AttachmentBundle\Form\Handler\AttachmentHandler:
        alias: oro_attachment.form.handler.attachment

    oro_attachment.form.handler.attachment:
        public: true
        class: Oro\Bundle\AttachmentBundle\Form\Handler\AttachmentHandler
        arguments:
            - '@request_stack'
            - '@doctrine.orm.entity_manager'

    oro_attachment.form.multiple_file_subscriber:
        class: Oro\Bundle\AttachmentBundle\Form\EventSubscriber\MultipleFileSubscriber
        arguments:
            - '@oro_attachment.validator.multiple_file_config_validator'

    oro_attachment.validator.multiple_file_config_validator:
        class: Oro\Bundle\AttachmentBundle\Validator\ConfigMultipleFileValidator
        arguments:
            - '@validator'

    oro_attachment.form.type.multiple_file:
        class: Oro\Bundle\AttachmentBundle\Form\Type\MultiFileType
        arguments:
            - '@oro_attachment.form.multiple_file_subscriber'
            - '@oro_attachment.provider.multiple_files_constraints'
        tags:
            - { name: form.type, alias: oro_attachment_multi_file }

    oro_attachment.type.content_file_type:
        class: Oro\Bundle\AttachmentBundle\Form\Type\ContentFileType
        arguments:
            - '@oro_attachment.data_transformer.content_file_data_transformer'
        tags:
            - { name: form.type }

    oro_attachment.data_transformer.content_file_data_transformer:
        class: Oro\Bundle\AttachmentBundle\Form\DataTransformer\ContentFileDataTransformer
