parameters:
    oro_imap.user_form_name:                         oro_user_emailsettings
    oro_imap.user_form_type:                         oro_user_emailsettings
    oro_imap.email_mailbox_form_name:                oro_email_mailbox
    oro_imap.email_mailbox_form_type:                oro_email_mailbox
    oro_imap.connector.factory.class:                Oro\Bundle\ImapBundle\Connector\ImapConnectorFactory
    oro_imap.connector.class:                        Oro\Bundle\ImapBundle\Connector\ImapConnector
    oro_imap.services.factory.class:                 Oro\Bundle\ImapBundle\Connector\ImapServicesFactory
    oro_imap.search_string_manager.gmail.class:      Oro\Bundle\ImapBundle\Connector\Search\GmailSearchStringManager
    oro_imap.search_string_manager.other.class:      Oro\Bundle\ImapBundle\Connector\Search\SearchStringManager
    oro_imap.storage.gmail.class:                    Oro\Bundle\ImapBundle\Mail\Storage\GmailImap
    oro_imap.storage.other.class:                    Oro\Bundle\ImapBundle\Mail\Storage\Imap
    oro_imap.email_body_loader.class:                Oro\Bundle\ImapBundle\Provider\ImapEmailBodyLoader
    oro_imap.email_flag_manager_loader.class:        Oro\Bundle\ImapBundle\Provider\ImapEmailFlagManagerLoader
    oro_imap.email_synchronizer.class:               Oro\Bundle\ImapBundle\Sync\ImapEmailSynchronizer
    oro_imap.email_sync_processor_factory.class:     Oro\Bundle\ImapBundle\Sync\ImapEmailSynchronizationProcessorFactory
    oro_imap.imap_email_remove_manager.class:        Oro\Bundle\ImapBundle\Sync\ImapEmailRemoveManager
    oro_imap.imap_clear_manager.class:               Oro\Bundle\ImapBundle\Manager\ImapClearManager
    oro_imap.workflow.action.dependency_job.class:   Oro\Bundle\ImapBundle\Workflow\Action\DependencyJob

    oro_imap.form.type.configuration.class:          Oro\Bundle\ImapBundle\Form\Type\ConfigurationType
    oro_imap.form.type.check_button.class:           Oro\Bundle\ImapBundle\Form\Type\CheckButtonType
    oro_imap.form.type.google_sync_checkbox.class:   Oro\Bundle\ImapBundle\Form\Type\GoogleSyncConfigCheckbox
    oro_imap.form.type.choice_account.class:         Oro\Bundle\ImapBundle\Form\Type\ChoiceAccountType
    oro_imap.form.configuration_gmail_type.class:    Oro\Bundle\ImapBundle\Form\Type\ConfigurationGmailType

    oro_imap.listener.user_email_origin.class:       Oro\Bundle\ImapBundle\EventListener\UserEmailOriginListener
    oro_imap.listener.send_email_transport_listener.class: Oro\Bundle\ImapBundle\EventListener\SendEmailTransportListener

    oro_imap.imap_email_google_oauth2_manager.class: Oro\Bundle\ImapBundle\Manager\ImapEmailGoogleOauth2Manager

    oro_imap.manager.connection_controller_manager.class: Oro\Bundle\ImapBundle\Manager\ConnectionControllerManager

services:
    oro_imap.connector.factory:
        class: %oro_imap.connector.factory.class%
        arguments:
            - '@oro_imap.services.factory'
            - %oro_imap.connector.class%

    oro_imap.services.factory:
        public: false
        class: %oro_imap.services.factory.class%
        arguments:
            - # The configuration of IMAP services. The empty key is used to configure IMAP servers which have not any special preferences
                "": [%oro_imap.storage.other.class%, %oro_imap.search_string_manager.other.class%]
                X-GM-EXT-1: [%oro_imap.storage.gmail.class%, %oro_imap.search_string_manager.gmail.class%]

    oro_imap.email_body_loader:
        public: false
        class: %oro_imap.email_body_loader.class%
        arguments:
            - '@oro_imap.connector.factory'
            - '@oro_security.encoder.mcrypt'
            - '@oro_imap.imap_email_google_oauth2_manager'
            - '@oro_config.global'
        tags:
            - { name: oro_email.email_body_loader }

    oro_imap.email_flag_manager_loader:
        public: false
        class: %oro_imap.email_flag_manager_loader.class%
        arguments:
            - '@oro_imap.connector.factory'
            - '@oro_security.encoder.mcrypt'
            - '@oro_imap.imap_email_google_oauth2_manager'
        tags:
            - { name: oro_email.email_flag_manager_loader }

    oro_imap.email_synchronizer:
        scope: prototype
        class: %oro_imap.email_synchronizer.class%
        arguments:
            - '@doctrine'
            - '@oro_email.known_email_address_checker_factory'
            - '@oro_imap.email_sync_processor_factory'
            - '@oro_imap.connector.factory'
            - '@oro_security.encoder.mcrypt'
            - '@oro_imap.imap_email_google_oauth2_manager'
        calls:
            - [setJobManager, ['@oro_cron.job_manager']]
        tags:
            - { name: oro_email.email_synchronizer }

    oro_imap.email_sync_processor_factory:
        class: %oro_imap.email_sync_processor_factory.class%
        public: false
        scope: prototype
        arguments:
            - '@doctrine'
            - '@oro_email.email.entity.builder'
            - '@oro_imap.imap_email_remove_manager'

    oro_imap.imap_email_remove_manager:
        class: %oro_imap.imap_email_remove_manager.class%
        arguments:
            - '@doctrine'
        calls:
            - [setLogger, ['@logger']]

    oro_imap.form.type.configuration:
        class: %oro_imap.form.type.configuration.class%
        arguments:
            - '@oro_security.encoder.mcrypt'
            - '@oro_security.security_facade'
            - '@translator'
        tags:
             - { name: form.type, alias: oro_imap_configuration }

    oro_imap.form.type.check_button:
        class: %oro_imap.form.type.check_button.class%
        tags:
            - { name: form.type, alias: oro_imap_configuration_check }

    oro_imap.form.type.choice_account:
        class: %oro_imap.form.type.choice_account.class%
        arguments:
             - '@translator'
        tags:
             - { name: form.type, alias: oro_imap_choice_account_type }

    oro_imap.form.configuration_gmail_type:
        class: %oro_imap.form.configuration_gmail_type.class%
        arguments:
             - '@translator'
             - '@oro_config.user'
             - '@oro_security.security_facade'
        tags:
             - { name: form.type, alias: oro_imap_configuration_gmail }

    oro_imap.listener.user_email_origin:
        class: %oro_imap.listener.user_email_origin.class%
        arguments:
            - '@oro_security.encoder.mcrypt'
            - '@oro_imap.connector.factory'
            - '@doctrine'
            - '@oro_imap.imap_email_google_oauth2_manager'
        tags:
            - { name: doctrine.event_listener, event: prePersist }

    oro_imap.manager.clear:
        class: %oro_imap.imap_clear_manager.class%
        arguments:
            - '@doctrine.orm.entity_manager'
            - '@oro_entity.event_listener.entity_modify_created_updated_properties_listener'
        calls:
            - [setLogger, ['@logger']]

    oro_imap.workflow.action.dependency_job:
        class: %oro_imap.workflow.action.dependency_job.class%
        arguments:
            - '@oro_action.context_accessor'
            - '@doctrine'
        tags:
            - { name: oro_workflow.action, alias: job_add_dependency }

    oro_imap.form.type.google_sync_checkbox:
        class: %oro_imap.form.type.google_sync_checkbox.class%
        tags:
            - { name: form.type, alias: oro_config_google_imap_sync_checkbox }

    oro_imap.form.google_imap_config_handler:
        class: Oro\Bundle\ImapBundle\Form\Handler\GoogleImapConfigHandler
        arguments:
            - '@doctrine'
            - '@oro_imap.imap_email_google_oauth2_manager'
            - '@logger'

    oro_imap.imap_email_google_oauth2_manager:
        class: %oro_imap.imap_email_google_oauth2_manager.class%
        arguments:
            - '@hwi_oauth.http_client'
            - '@hwi_oauth.resource_ownermap.main'
            - '@oro_config.global'
            - '@doctrine'

    oro_imap.manager.controller.connection:
        class: %oro_imap.manager.connection_controller_manager.class%
        scope: request
        arguments:
            - '@form.factory'
            - '@oro_security.encoder.mcrypt'
            - '@doctrine'
            - '@oro_imap.connector.factory'
            - '@oro_imap.imap_email_google_oauth2_manager'
            - %oro_imap.user_form_name%
            - %oro_imap.user_form_type%
            - %oro_imap.email_mailbox_form_name%
            - %oro_imap.email_mailbox_form_type%

    oro_imap.listener.send_email_transport_listener:
        class: %oro_imap.listener.send_email_transport_listener.class%
        arguments:
            - '@oro_security.encoder.mcrypt'
            - '@oro_imap.imap_email_google_oauth2_manager'
        tags:
            - { name: kernel.event_listener, event: oro_email.send_email_transport, method: setSmtpTransport }
