services:
    oro_email.form.subscriber.emailtemplate:
        class: Oro\Bundle\EmailBundle\Form\EventListener\BuildTemplateFormSubscriber
        arguments:
            - '@security.token_storage'

    oro_email.form.subscriber.autoresponserule:
        class: Oro\Bundle\EmailBundle\Form\EventListener\AutoResponseRuleSubscriber
        arguments:
            - '@oro_security.token_accessor'

    oro_email.form.type.autoresponserule:
        class: Oro\Bundle\EmailBundle\Form\Type\AutoResponseRuleType
        arguments:
            - '@oro_email.form.subscriber.autoresponserule'
        tags:
            - { name: form.type, alias: oro_email_autoresponserule }

    oro_email.form.type.autoresponse_template:
        class: Oro\Bundle\EmailBundle\Form\Type\AutoResponseTemplateType
        arguments:
            - '@oro_config.global'
            - '@oro_config.user'
            - '@doctrine'
            - '@oro_locale.manager.localization'
            - '@oro_ui.html_tag_helper'
        tags:
            - { name: form.type, alias: oro_email_autoresponse_template }

    oro_email.form.type.autoresponse_template_choice:
        class: Oro\Bundle\EmailBundle\Form\Type\AutoResponseTemplateChoiceType
        arguments:
            - '@oro_security.token_accessor'
            - '@translator'
        tags:
            - { name: form.type, alias: oro_email_autoresponse_template_choice }

    oro_email.form.extension.mailbox_unbound_rules:
        class: Oro\Bundle\EmailBundle\Form\Extension\MailboxUnboudRulesExtension
        arguments:
            - '@doctrine'
        tags:
            - { name: form.type_extension, alias: oro_email_mailbox, extended_type: Oro\Bundle\EmailBundle\Form\Type\MailboxType }

    oro_email.form.emailtemplate:
        class: Symfony\Component\Form\Form
        public: true
        factory: ['@form.factory', createNamed]
        arguments: ["oro_email_emailtemplate", Oro\Bundle\EmailBundle\Form\Type\EmailTemplateType, null]

    oro_email.form.type.emailtemplate:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailTemplateType
        arguments:
            - '@oro_config.user'
            - '@oro_locale.manager.localization'
        tags:
            - { name: form.type, alias: oro_email_emailtemplate }

    oro_email.form.email_template_localization_type:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailTemplateTranslationType
        arguments:
            - '@translator'
            - '@oro_locale.manager.localization'
        calls:
            - ['setConfigManager', ['@oro_config.manager']]
        tags:
            - { name: form.type }

    oro_email.form.type.emailtemplate_rich_text:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailTemplateRichTextType
        tags:
            - { name: form.type, alias: oro_email_template_rich_text }

    oro_email.form.type.emailtemplate_select:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailTemplateSelectType
        tags:
            - { name: form.type, alias: oro_email_template_list }

    oro_email.form.type.system_emailtemplate_select:
        class: Oro\Bundle\EmailBundle\Form\Type\SystemEmailTemplateSelectType
        arguments:
            - '@doctrine.orm.entity_manager'
        tags:
            - { name: form.type, alias: oro_email_system_template_list }

    Oro\Bundle\EmailBundle\Form\Handler\EmailTemplateHandler:
        alias: oro_email.form.handler.emailtemplate

    oro_email.form.handler.emailtemplate:
        class: Oro\Bundle\EmailBundle\Form\Handler\EmailTemplateHandler
        public: true
        arguments:
            - '@oro_email.form.emailtemplate'
            - '@request_stack'
            - '@doctrine.orm.entity_manager'
            - '@translator'

    oro_email.form.handler.email:
        class: Oro\Bundle\EmailBundle\Form\Handler\EmailHandler
        public: true
        arguments:
            - '@oro_email.form.email'
            - '@request_stack'
            - '@oro_email.sender.email_model_sender'
            - '@logger'

    Oro\Bundle\EmailBundle\Form\Handler\EmailHandler:
        alias: 'oro_email.form.handler.email'

    oro_email.form.email:
        class: Symfony\Component\Form\Form
        public: true
        factory: ['@form.factory', createNamed]
        arguments: ["oro_email_email", Oro\Bundle\EmailBundle\Form\Type\EmailType, null]

    Oro\Bundle\EmailBundle\Form\Type\EmailType:
        alias: 'oro_email.form.email'

    oro_email.form.type.email:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailType
        arguments:
            - '@security.authorization_checker'
            - '@oro_security.token_accessor'
            - '@oro_email.email_renderer'
            - '@oro_email.email.model.builder.helper'
            - '@oro_config.user'
        tags:
            - { name: form.type, alias: oro_email_email }

    oro_email.form.handler.email.api:
        class: Oro\Bundle\EmailBundle\Form\Handler\EmailApiHandler
        public: true
        arguments:
            - '@oro_email.form.email.api'
            - '@request_stack'
            - '@doctrine.orm.entity_manager'
            - "@oro_email.email.entity.builder"
            - '@oro_security.token_accessor'
            - '@event_dispatcher'
            - '@oro_email.email_importance_transformer'
            - '@oro_email.email_body_type_transformer'

    oro_email.form.email.api:
        class: Symfony\Component\Form\Form
        public: true
        factory: ['@form.factory', createNamed]
        arguments:
            - ''
            - Oro\Bundle\EmailBundle\Form\Type\EmailApiType

    oro_email.form.type.email.api:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailApiType
        tags:
            - { name: form.type, alias: oro_email_email_api }

    oro_email.form.type.email_folder.api:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailFolderApiType
        tags:
            - { name: form.type, alias: oro_email_email_folder_api }

    oro_email.form.type.email_address:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailAddressType
        tags:
            - { name: form.type, alias: oro_email_email_address }

    oro_email.form.type.email_address.api:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailAddressApiType
        tags:
            - { name: form.type, alias: oro_email_email_address_api }

    oro_email.form.type.attachment:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailAttachmentType
        arguments:
            - '@doctrine'
            - '@oro_email.email_attachment_transformer'
        tags:
            - { name: form.type, alias: oro_email_attachment }

    oro_email.form.type.attachments:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailAttachmentsType
        tags:
            - { name: form.type, alias: oro_email_attachments }

    oro_email.form.type.email_link_to_scope:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailLinkToScopeType
        tags:
            - { name: form.type, alias: oro_email_link_to_scope }

    oro_email.form.type.mailbox_grid:
        class: Oro\Bundle\EmailBundle\Form\Type\MailboxGridType
        tags:
            - { name: form.type, alias: oro_email_mailbox_grid }

    oro_email.form.type.mailbox:
        class: Oro\Bundle\EmailBundle\Form\Type\MailboxType
        arguments:
            - '@oro_email.mailbox.process_storage'
            - '@oro_security.encoder.default'
            - '@oro_imap.oauth_manager_registry'
        tags:
            - { name: form.type, alias: oro_email_mailbox }

    oro_email.form.handler.mailbox:
        class: Oro\Bundle\EmailBundle\Form\Handler\MailboxHandler
        public: true
        arguments:
            - '@form.factory'
            - '@request_stack'
            - '@doctrine'
            - '@oro_email.mailbox.process_storage'
            - '@event_dispatcher'

    oro_email.form.handler.email_configuration:
        class: Oro\Bundle\EmailBundle\Form\Handler\EmailConfigurationHandler
        public: true
        arguments:
            - '@event_dispatcher'

    oro_email.form.configurator.email_configuration:
        class: Oro\Bundle\EmailBundle\Form\Configurator\EmailConfigurationConfigurator
        public: true
        arguments:
            - '@oro_security.encoder.default'
            - '@validator'

    oro_email.form.factory:
        class: Oro\Bundle\EmailBundle\Form\Model\Factory

    oro_email.form.type.email_folder_tree:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailFolderTreeType
        tags:
            - { name: form.type, alias: oro_email_email_folder_tree }

    oro_email.form.type.filter.originfolder:
        class: Oro\Bundle\EmailBundle\Form\Type\Filter\ChoiceOriginFolderFilterType
        arguments: ["@translator"]
        tags:
            - { name: form.type, alias: oro_type_originfolder_filter }

    oro_email.form.type.email_address_from:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailAddressFromType
        arguments:
            - '@oro_security.token_accessor'
            - '@oro_email.related_emails.provider'
            - '@oro_email.mailbox.manager'
        tags:
            - { name: form.type, alias: oro_email_email_address_from }

    oro_email.form.type.email_origin_from:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailOriginFromType
        arguments:
            - '@oro_security.token_accessor'
            - '@oro_email.related_emails.provider'
            - '@oro_email.email.model.builder.helper'
            - '@oro_email.mailbox.manager'
            - '@doctrine'
            - '@oro_email.tools.email_origin_helper'
        tags:
            - { name: form.type, alias: oro_email_email_origin_from }

    oro_email.form.type.email_address_recipients:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailAddressRecipientsType
        arguments:
            - '@oro_config.global'
        tags:
            - { name: form.type, alias: oro_email_email_address_recipients }

    oro_email.form.extension.email_type_template_asscessibility_checker_extension:
        class: Oro\Bundle\EmailBundle\Form\Extension\EmailTypeTemplateAccessibilityCheckerExtension
        arguments:
            - '@security.authorization_checker'
        tags:
            - { name: form.type_extension, extended_type: Oro\Bundle\EmailBundle\Form\Type\EmailType }

    oro_email.form.type.email_template_entity_choice:
        class: Oro\Bundle\EmailBundle\Form\Type\EmailTemplateEntityChoiceType
        arguments:
            - '@oro_email.email_template_entity_provider'
        tags:
            - { name: form.type }
